本文整理汇总了C#中System.Windows.UIElement.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.Focus方法的具体用法?C# UIElement.Focus怎么用?C# UIElement.Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.UIElement
的用法示例。
在下文中一共展示了UIElement.Focus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Focus
public static void Focus( UIElement element )
{
if( !element.Focus() )
{
element.Dispatcher.BeginInvoke( DispatcherPriority.Input, new ThreadStart( delegate() {
element.Focus();
} ));
}
}
示例2: GiveFocus
/// <summary>
/// Gives the focus to the given UIElement.
/// </summary>
/// <param name="element">The UIElement which has to get the focus.</param>
/// <remarks>Giving the focus will be done using the target element dispatcher with the <see cref="System.Windows.Threading.DispatcherPriority.Render" /> priority.</remarks>
public static void GiveFocus(UIElement element)
{
element.Dispatcher.BeginInvoke(new Action(delegate
{
element.Focus();
Keyboard.Focus(element);
}),
DispatcherPriority.Render);
}
示例3: GetObservable
private IObservable<Vector2> GetObservable(UIElement target, string eventName, UIElement relative, Func<Point, Point> translate)
{
return Observable.FromEventPattern<MouseEventArgs>(target, eventName).Select(
e =>
{
target.Focus();
return ToVector2(translate(e.EventArgs.GetPosition(relative)));
});
}
示例4: PutFocus
private void PutFocus(UIElement uiElement)
{
if (ShouldUseKeyboardFocusMethod.IsChecked.GetValueOrDefault())
{
Keyboard.Focus(uiElement);
}
else
{
uiElement.Focus();
}
}
示例5: SetFocus
private void SetFocus(UIElement element)
{
if (element.Focusable)
{
element.Focus();
}
else
{
element.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
}
}