FindChild() 개인적인 정적인 메소드

private static FindChild ( DependencyObject parent, string childName ) : DependencyObject
parent System.Windows.DependencyObject
childName string
리턴 System.Windows.DependencyObject
예제 #1
0
        private static DependencyObject FindChild(DependencyObject parent, string childName)
        {
            if (parent == null)
            {
                return(null);
            }

            int childrenCount = VisualTreeHelper.GetChildrenCount(parent);

            for (int i = 0; i < childrenCount; i++)
            {
                DependencyObject child            = VisualTreeHelper.GetChild(parent, i);
                FrameworkElement frameworkElement = child as FrameworkElement;

                if (frameworkElement != null && frameworkElement.Name == childName)
                {
                    return(frameworkElement);
                }

                child = StatusBarInjector.FindChild(child, childName);

                if (child != null)
                {
                    return(child);
                }
            }

            return(null);
        }
예제 #2
0
 private void FindStatusBar()
 {
     _statusBar = StatusBarInjector.FindChild(_window, "StatusBarContainer") as FrameworkElement;
     _panel     = _statusBar.Parent as DockPanel;
 }