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


C# IInputElement.GetVisualChildren方法代码示例

本文整理汇总了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;
                    }
                }
            }
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:26,代码来源:DirectionalNavigation.cs

示例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;
                    }
                }
            }
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:47,代码来源:TabNavigation.cs

示例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;
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:31,代码来源:KeyboardNavigationHandler.cs

示例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();
 }
开发者ID:Robertofon,项目名称:Perspex,代码行数:14,代码来源:KeyboardNavigationHandler.cs

示例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;
                    }
                }
            }
        }
开发者ID:jkoritzinsky,项目名称:Avalonia,代码行数:25,代码来源:DirectionalNavigation.cs


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