在 C#PropertyInspectorView
中属于 Type UIElement
。
我需要得到PropertyInspectorView
. 没有内在的方法可以做到这一点。既然继承了,UIElement
我想知道是否有办法得到 aUIElement
的孩子。
感谢您的关注。这个问题不是已经提出的问题的重复。已经提出的问题有一个 xaml 部分。我的问题是关于没有 XAML 连接和purley C# 的代码。请尽可能删除重复的标签。谢谢-
在 C#PropertyInspectorView
中属于 Type UIElement
。
我需要得到PropertyInspectorView
. 没有内在的方法可以做到这一点。既然继承了,UIElement
我想知道是否有办法得到 aUIElement
的孩子。
感谢您的关注。这个问题不是已经提出的问题的重复。已经提出的问题有一个 xaml 部分。我的问题是关于没有 XAML 连接和purley C# 的代码。请尽可能删除重复的标签。谢谢-
您可以使用
ControlTypeIWantToFind result =
FindVisualChild<ControlTypeIWantToFind>(myPropertyInspectorView);
public static T FindVisualChild<T>(DependencyObject depObj) where T : DependencyObject
{
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
{
return (T)child;
}
T childItem = FindVisualChild<T>(child);
if (childItem != null) return childItem;
}
}
return null;
}