1

在 C#PropertyInspectorView中属于 Type UIElement

http://msdn.microsoft.com/en-us/library/system.activities.presentation.workflowdesigner.propertyinspectorview.aspx

我需要得到PropertyInspectorView. 没有内在的方法可以做到这一点。既然继承了,UIElement我想知道是否有办法得到 aUIElement的孩子。

感谢您的关注。这个问题不是已经提出的问题的重复。已经提出的问题有一个 xaml 部分。我的问题是关于没有 XAML 连接和purley C# 的代码。请尽可能删除重复的标签。谢谢-

4

1 回答 1

6

您可以使用

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;
}
于 2013-10-16T17:34:09.343 回答