FindVisualChild
Posted rr-ghost
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FindVisualChild相关的知识,希望对你有一定的参考价值。
public static List<T> FindVisualChild<T>(DependencyObject obj) where T : DependencyObject { try { List<T> TList = new List<T> { }; for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) { DependencyObject child = VisualTreeHelper.GetChild(obj, i); if (child != null && child is T) { TList.Add((T)child); List<T> childOfChildren = FindVisualChild<T>(child); if (childOfChildren != null) { TList.AddRange(childOfChildren); } } else { List<T> childOfChildren = FindVisualChild<T>(child); if (childOfChildren != null) { TList.AddRange(childOfChildren); } } } return TList; } catch (Exception ee) { } }
以上是关于FindVisualChild的主要内容,如果未能解决你的问题,请参考以下文章