Question

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–

Was it helpful?

Solution

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top