当前位置: 首页>>代码示例>>C#>>正文


C# UIElement.MoveFocus方法代码示例

本文整理汇总了C#中System.Windows.UIElement.MoveFocus方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.MoveFocus方法的具体用法?C# UIElement.MoveFocus怎么用?C# UIElement.MoveFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.UIElement的用法示例。


在下文中一共展示了UIElement.MoveFocus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetFocusOnActiveElementInScope

 public static void SetFocusOnActiveElementInScope(UIElement scope)
 {
     IInputElement focusedElement = FocusManager.GetFocusedElement(scope);
     if (focusedElement != null)
     {
         Keyboard.Focus(focusedElement);
     }
     else
     {
         scope.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
     }
 }
开发者ID:powernick,项目名称:CodeLib,代码行数:12,代码来源:TestFocusScope.xaml.cs

示例2: HandleDropDownKeyDown

        internal static void HandleDropDownKeyDown(
            object sender, KeyEventArgs e, Func<bool> gettor, Action<bool> settor, UIElement targetFocusOnFalse, UIElement targetFocusContainerOnTrue)
        {
            Key key = e.Key;
            switch (key)
            {
                case Key.Escape:
                    {
                        if (gettor())
                        {
                            settor(false);
                            e.Handled = true;
                            if (targetFocusOnFalse != null)
                            {
                                targetFocusOnFalse.Focus();
                            }
                        }
                    }
                    break;

                case Key.System:
                    if ((e.SystemKey == Key.LeftAlt) ||
                        (e.SystemKey == Key.RightAlt) ||
                        (e.SystemKey == Key.F10))
                    {
                        if (gettor())
                        {
                            // Raise DismissPopup event and hence the key down event.
                            UIElement uie = sender as UIElement;
                            if (uie != null)
                            {
                                RibbonDismissPopupEventArgs dismissArgs = new RibbonDismissPopupEventArgs();
                                uie.RaiseEvent(dismissArgs);
                                e.Handled = true;
                            }
                        }
                    }
                    break;
                case Key.F4:
                    {
                        if (gettor())
                        {
                            settor(false);
                            e.Handled = true;
                            if (targetFocusOnFalse != null)
                            {
                                targetFocusOnFalse.Focus();
                            }
                        }
                        else
                        {
                            settor(true);
                            if (targetFocusContainerOnTrue != null)
                            {
                                targetFocusContainerOnTrue.Dispatcher.BeginInvoke(
                                    (Action)delegate()
                                    {
                                        targetFocusContainerOnTrue.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
                                    },
                                    DispatcherPriority.Input,
                                    null);
                            }
                            e.Handled = true;
                        }

                        // Technically one needs to change active key tip scope,
                        // but since we do not have public api to do that yet,
                        // we dismiss keytips
                        KeyTipService.DismissKeyTips();
                    }
                    break;
            }
        }
开发者ID:kasicass,项目名称:kasicass,代码行数:73,代码来源:RibbonHelper.cs

示例3: SetFocus

 private void SetFocus(UIElement element)
 {
     if (element.Focusable)
     {
         element.Focus();
     }
     else
     {
         element.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
     }
 }
开发者ID:40a,项目名称:PowerShell,代码行数:11,代码来源:DismissiblePopup.cs

示例4: CallShortcutKeys


//.........这里部分代码省略.........
                            MessageBox.Show("Ctrl + NumPad2");
                            e.Handled = true;
                            break;
                        case Key.NumPad3:
                            MessageBox.Show("Ctrl + NumPad3");
                            e.Handled = true;
                            break;
                        case Key.PageDown:
                            MessageBox.Show("Ctrl + PageDown");
                            e.Handled = true;
                            break;
                        case Key.PageUp:
                            MessageBox.Show("Ctrl + PageUp");
                            e.Handled = true;
                            break;
                        case Key.Tab:
                            MessageBox.Show("Ctrl + Tab");
                            e.Handled = true;
                            break;
                        case Key.Delete:
                            MessageBox.Show("Ctrl + Delete");
                            e.Handled = true;
                            break;
                        case Key.Enter:
                            MessageBox.Show("Ctrl + Enter");
                            e.Handled = true;
                            break;
                        case Key.F6:
                            _tRequest = new TraversalRequest(FocusNavigationDirection.Previous);
                            _focusedElement = Keyboard.FocusedElement as UIElement;

                            if (_focusedElement != null)
                            {
                                _focusedElement.MoveFocus(_tRequest);
                            }
                            e.Handled = true;
                            break;
                    }
                }
                else if ((Keyboard.Modifiers & (ModifierKeys.Alt | ModifierKeys.Shift | ModifierKeys.Control)) == (ModifierKeys.Alt | ModifierKeys.Shift | ModifierKeys.Control))
                {
                    switch (e.Key)
                    {
                        case Key.Enter:
                            //MessageBox.Show("Ctrl + Alt + Shift + Enter");
                            MenuItem_Click_NewVolume(this,null);
                            e.Handled = true;
                            break;
                    }
                }
                else if (Keyboard.Modifiers == ModifierKeys.Shift)
                {
                    switch (e.Key)
                    {
                        case Key.F3:
                            MessageBox.Show("Shift + F3");
                            e.Handled = true;
                            break;
                    }
                }
                else if (Keyboard.Modifiers == ModifierKeys.Alt)
                {
                    switch (altKey)
                    {
                        case Key.D1:
                            MessageBox.Show("Alt + 1");
开发者ID:ethno2405,项目名称:BrailleTranslator,代码行数:67,代码来源:frmMain.xaml.cs

示例5: MenuItem_Click_F6

        private void MenuItem_Click_F6(object sender, RoutedEventArgs e)
        {
            _tRequest = new TraversalRequest(FocusNavigationDirection.Next);
            _focusedElement = Keyboard.FocusedElement as UIElement;

            if (_focusedElement != null)
            {
                _focusedElement.MoveFocus(_tRequest);
            }
            e.Handled = true;
        }
开发者ID:ethno2405,项目名称:BrailleTranslator,代码行数:11,代码来源:frmMain.xaml.cs


注:本文中的System.Windows.UIElement.MoveFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。