本文整理汇总了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));
}
}
示例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;
}
}
示例3: SetFocus
private void SetFocus(UIElement element)
{
if (element.Focusable)
{
element.Focus();
}
else
{
element.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
}
}
示例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");
示例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;
}