System.Windows.FrameworkElementExtensions.FindNameRecursive C# (CSharp) Method

FindNameRecursive() public static method

public static FindNameRecursive ( this element, string name ) : object
element this
name string
return object
        public static object FindNameRecursive(this FrameworkElement element, string name)
        {
            FrameworkElement rootVisual = element.GetRootVisual();
            if (rootVisual == null) {
                return null;
            }

            return rootVisual.FindName(name);
            #if FALSE
            while (element != null) {
                object value = element.FindName(name);
                if (value != null) {
                    return value;
                }

                element = element.GetParent();
            }

            return null;
            #endif
        }