WPF 控件回车移动焦点

1.Set the TabIndex="16"
2.
 private void detailGrid_Keydown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Enter)
                {
                    TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);

                    UIElement focusElement = Keyboard.FocusedElement as UIElement;
                    if (focusElement != null)
                    {
                        focusElement.MoveFocus(request);
                    }
                    e.Handled = true;
                }
            }
            catch (Exception e1)
            {
                ExceptionDialog.Show(e1);
            }
        }

 

posted @ 2014-01-23 19:54  quietwalk  阅读(2956)  评论(0编辑  收藏  举报