本文整理汇总了C#中IInputElement.GetVisualChildren方法的典型用法代码示例。如果您正苦于以下问题:C# IInputElement.GetVisualChildren方法的具体用法?C# IInputElement.GetVisualChildren怎么用?C# IInputElement.GetVisualChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInputElement
的用法示例。
在下文中一共展示了IInputElement.GetVisualChildren方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFocusableDescendents
/// <summary>
/// Gets the focusable descendents of the specified element.
/// </summary>
/// <param name="element">The element.</param>
/// <returns>The element's focusable descendents.</returns>
private static IEnumerable<IInputElement> GetFocusableDescendents(IInputElement element)
{
var mode = KeyboardNavigation.GetDirectionalNavigation((InputElement)element);
var children = element.GetVisualChildren().OfType<IInputElement>();
foreach (var child in children)
{
if (child.CanFocus())
{
yield return child;
}
if (child.CanFocusDescendents())
{
foreach (var descendent in GetFocusableDescendents(child))
{
yield return descendent;
}
}
}
}
示例2: GetFocusableDescendents
/// <summary>
/// Gets the focusable descendents of the specified element.
/// </summary>
/// <param name="element">The element.</param>
/// <returns>The element's focusable descendents.</returns>
private static IEnumerable<IInputElement> GetFocusableDescendents(IInputElement element)
{
var mode = KeyboardNavigation.GetTabNavigation((InputElement)element);
if (mode == KeyboardNavigationMode.None)
{
yield break;
}
var children = element.GetVisualChildren().OfType<IInputElement>();
if (mode == KeyboardNavigationMode.Once)
{
var active = KeyboardNavigation.GetTabOnceActiveElement((InputElement)element);
if (active != null)
{
yield return active;
yield break;
}
else
{
children = children.Take(1);
}
}
foreach (var child in children)
{
if (child.CanFocus())
{
yield return child;
}
if (child.CanFocusDescendents())
{
foreach (var descendent in GetFocusableDescendents(child))
{
yield return descendent;
}
}
}
}
示例3: 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>
/// <returns>The next element, or null if the element is the last.</returns>
private static IInputElement GetNextInContainer(IInputElement element, IInputElement container)
{
var descendent = GetDescendents(element).FirstOrDefault();
if (descendent != null)
{
return descendent;
}
else if (container != null)
{
var sibling = container.GetVisualChildren()
.OfType<IInputElement>()
.Where(CanFocus)
.SkipWhile(x => x != element)
.Skip(1)
.FirstOrDefault();
if (sibling != null)
{
return sibling;
}
}
return null;
}
示例4: GetPreviousInContainer
/// <summary>
/// Gets the previous item that should be focused in the specified container.
/// </summary>
/// <param name="element">The starting element/</param>
/// <param name="container">The container.</param>
/// <returns>The previous element, or null if the element is the first.</returns>
private static IInputElement GetPreviousInContainer(IInputElement element, IInputElement container)
{
return container.GetVisualChildren()
.OfType<IInputElement>()
.Where(CanFocus)
.TakeWhile(x => x != element)
.LastOrDefault();
}
示例5: GetFocusableDescendents
/// <summary>
/// Gets the focusable descendents of the specified element.
/// </summary>
/// <param name="element">The element.</param>
/// <returns>The element's focusable descendents.</returns>
private static IEnumerable<IInputElement> GetFocusableDescendents(IInputElement element)
{
var children = element.GetVisualChildren().OfType<IInputElement>();
foreach (var child in children)
{
if (child.CanFocus())
{
yield return child;
}
if (child.CanFocusDescendents())
{
foreach (var descendent in GetFocusableDescendents(child))
{
yield return descendent;
}
}
}
}