本文整理汇总了C#中IInputElement.CanFocus方法的典型用法代码示例。如果您正苦于以下问题:C# IInputElement.CanFocus方法的具体用法?C# IInputElement.CanFocus怎么用?C# IInputElement.CanFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInputElement
的用法示例。
在下文中一共展示了IInputElement.CanFocus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNextInContainer
/// <summary>
/// Gets the next item that should be focused in the specified container.
/// </summary>
/// <param name="element">The starting element/</param>
/// <param name="container">The container.</param>
/// <param name="direction">The direction.</param>
/// <returns>The next element, or null if the element is the last.</returns>
private static IInputElement GetNextInContainer(
IInputElement element,
IInputElement container,
FocusNavigationDirection direction)
{
if (direction == FocusNavigationDirection.Down)
{
var descendent = GetFocusableDescendents(element).FirstOrDefault();
if (descendent != null)
{
return descendent;
}
}
if (container != null)
{
var navigable = container as INavigableContainer;
if (navigable != null)
{
while (element != null)
{
element = navigable.GetControl(direction, element);
if (element != null && element.CanFocus())
{
break;
}
}
}
else
{
// TODO: Do a spatial search here if the container doesn't implement
// INavigableContainer.
element = null;
}
if (element != null && direction == FocusNavigationDirection.Up)
{
var descendent = GetFocusableDescendents(element).LastOrDefault();
if (descendent != null)
{
return descendent;
}
}
return element;
}
return null;
}