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


C# DependencyObject.GetVisualChildren方法代码示例

本文整理汇总了C#中System.Windows.DependencyObject.GetVisualChildren方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.GetVisualChildren方法的具体用法?C# DependencyObject.GetVisualChildren怎么用?C# DependencyObject.GetVisualChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.DependencyObject的用法示例。


在下文中一共展示了DependencyObject.GetVisualChildren方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindControl

        private DependencyObject FindControl(string id, DependencyObject currentParent)
        {
            var currChildren = currentParent.GetVisualChildren();
            foreach (var item in currChildren)
            {
                if (item.GetValue(NameProperty).ToString().Equals(id))
                    return item;

                var childItem = FindControl(id, item);
                if (childItem != null)
                    return childItem;
            }

            return null;
        }
开发者ID:kasq,项目名称:silverlight-selenium,代码行数:15,代码来源:MainPageFixture.xaml.cs

示例2: FindLogicalNode

        /// <summary>
        /// Finds a logical node in the tree of the specified <see cref="DependencyObject"/>.
        /// </summary>
        /// <param name="dependencyObject">The dependency object.</param>
        /// <param name="name">The name of the control to find.</param>
        /// <returns>Child as <see cref="DependencyObject"/> or <c>null</c> if the child cannot be found.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="dependencyObject"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="name"/> is <c>null</c> or whitespace.</exception>
        public static DependencyObject FindLogicalNode(DependencyObject dependencyObject, string name)
        {
            Argument.IsNotNull("dependencyObject", dependencyObject);
            Argument.IsNotNullOrWhitespace("name", name);

            // Check if the object is the node itself
            if (IsElementWithName(dependencyObject, name))
            {
                return dependencyObject;
            }

            // Search all child nodes
            var children = new List<DependencyObject>(dependencyObject.GetVisualChildren());
            foreach (DependencyObject child in children)
            {
                if (IsElementWithName(child, name))
                {
                    return child;
                }
            }

            // Since we didn't find anything, check the childs of all childs
            return children.Select(child => FindLogicalNode(child, name)).FirstOrDefault(foundChild => foundChild != null);
        }
开发者ID:JaysonJG,项目名称:Catel,代码行数:32,代码来源:LogicalTreeHelper.cs

示例3: HasStringInSomePropertyOfItselfOrChildren

 private bool HasStringInSomePropertyOfItselfOrChildren(DependencyObject node, string value)
 {
     foreach (var property in node.GetType().GetProperties())
     {
         if (property.CanRead && property.GetValue(node, null) as string == value)
         {
             return true;
         }
     }
     foreach (var child in node.GetVisualChildren())
     {
         if (HasStringInSomePropertyOfItselfOrChildren(child, value))
         {
             return true;
         }
     }
     return false;
 }
开发者ID:ekostadinov,项目名称:MyProjects,代码行数:18,代码来源:SilverlightFixture.xaml.cs

示例4: GetStringsFromPropertiesOfItselfAndChildren

 private string GetStringsFromPropertiesOfItselfAndChildren(DependencyObject node, string currentStrings)
 {
     foreach (var property in node.GetType().GetProperties())
     {
         if (property.CanRead)
         {
             currentStrings += "|" + property.GetValue(node, null);
         }
     }
     foreach (var child in node.GetVisualChildren())
     {
         currentStrings = GetStringsFromPropertiesOfItselfAndChildren(child, currentStrings);
     }
     return currentStrings;
 }
开发者ID:ekostadinov,项目名称:MyProjects,代码行数:15,代码来源:SilverlightFixture.xaml.cs

示例5: FindChildrenByType

 private void FindChildrenByType(DependencyObject parent, Type type, ICollection<DependencyObject> children)
 {
     if (parent.GetType() == type)
     {
         children.Add(parent);
     }
     foreach (var child in parent.GetVisualChildren())
     {
         FindChildrenByType(child, type, children);
     }
 }
开发者ID:ekostadinov,项目名称:MyProjects,代码行数:11,代码来源:SilverlightFixture.xaml.cs

示例6: Describe

 private string Describe(DependencyObject node, string identation)
 {
     var description = identation == string.Empty ? "" : identation.Substring(0, identation.Length - 1) + "-";
     description += node;
     description += !string.IsNullOrEmpty(node.GetValue(NameProperty).ToString())
         ? " - " + node.GetValue(NameProperty) : "";
     if (node.GetType() == typeof(TextBlock))
     {
         description += " - " + ((TextBlock)node).Text;
     }
     description += "\n";
     foreach (var child in node.GetVisualChildren())
     {
         description += Describe(child, identation + "| ");
     }
     return description;
 }
开发者ID:ekostadinov,项目名称:MyProjects,代码行数:17,代码来源:SilverlightFixture.xaml.cs

示例7: GetChildren

 protected override IEnumerable<DependencyObject> GetChildren(DependencyObject dependencyObject)
 {
     return dependencyObject.GetVisualChildren ();
 }
开发者ID:mrange,项目名称:T4Include,代码行数:4,代码来源:DebugVisualTreeControl.cs


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