1、窗体基类实现参考
http://weblogs.asp.net/psheriff/archive/2009/11/02/creating-a-base-window-class-in-wpf.aspx
2、基类不能像WinForm窗体一样写Loaded事件(写了也是不执行的)
没办法只好写一个方法让所有继承者调用了
3、回车键改为TAB的实现
/// <summary>
/// 将回车改为TAB
/// </summary>
/// <param name="e"></param>
protected override void OnKeyDown(System.Windows.Input.KeyEventArgs e)
{
if (e.Key == System.Windows.Input.Key.Enter)
{
// MoveFocus takes a TraveralReqest as its argument.
TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
// Gets the element with keyboard focus.
UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;
// Change keyboard focus.
if (elementWithFocus != null)
{
elementWithFocus.MoveFocus(request);
}
e.Handled = true;
}
base.OnKeyDown(e);
}
欢迎访问:http://121.18.78.216 适易查询分析、工作流、内容管理及项目管理演示平台