uielementactivationservice.cs

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

CS
43 行
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;

namespace Microsoft.Practices.CompositeUI.Windows.Activation
{
	public class UIElementActivationService : IUIElementActivationService
	{
		private WorkItem _workItem;

		/// <summary>
		/// The <see cref="WorkItem"/> where this service lives.
		/// </summary>
		[ServiceDependency]
		public WorkItem WorkItem
		{
			set
			{
				_workItem = value;
			}
		}

		public void UIElementAdded(UIElement uiElement)
		{
			uiElement.GotFocus += uiElement_GotFocus;
		}

		public void UIElementRemoved(UIElement uiElement)
		{
			uiElement.GotFocus -= uiElement_GotFocus;
		}

		void uiElement_GotFocus(object sender, RoutedEventArgs e)
		{
			if (_workItem != null)
			{
				_workItem.Activate();
			}
		}
	}
}

⌨️ 快捷键说明

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