문제

In C# PropertyInspectorView is of Type UIElement.

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

I need to get the children of PropertyInspectorView. There is no inhernet method to do that. Since that inherits UIElement I wonder if there is a way to get a UIElement's children.

Thank you for your attention. This question is not the duplicate of a question already asked. The already asked questions have a xaml section to them. My question here is about code with no XAML connection and purley C#. Please remove the duplicate tag when possible. Thanks–

도움이 되었습니까?

해결책

You can use

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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top