frameworkelementcommandadapter.cs

来自「wpf和cab的结合使用源码(转载)」· CS 代码 · 共 38 行

CS
38 行
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Practices.CompositeUI.Utility;
using Microsoft.Practices.CompositeUI.Commands;

namespace Microsoft.Practices.CompositeUI.Windows
{
	/// <summary>
	/// Adapts between a WPF <see cref="FrameworkElement"/> and a CAB <see cref="Command"/>.
	/// </summary>
	public class FrameworkElementCommandAdapter : EventCommandAdapter<FrameworkElement>
	{
		public FrameworkElementCommandAdapter() 
			: base()
		{
		}

		public FrameworkElementCommandAdapter(FrameworkElement item, string eventName)
			: base(item, eventName)
		{
		}

		protected override void OnCommandChanged(Command command)
		{
			base.OnCommandChanged(command);

			foreach (FrameworkElement key in Invokers.Keys)
			{
				key.IsEnabled = (command.Status == CommandStatus.Enabled);
				key.Visibility = (command.Status == CommandStatus.Unavailable) ? Visibility.Collapsed : Visibility.Visible;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?