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); if (child is FrameworkElement frameworkElement && frameworkElement.Name == childName) { return(frameworkElement); } child = StatusBarInjector.FindChild(child, childName); if (child != null) { return(child); } } return(null); }
private void FindStatusBar() { _statusBar = StatusBarInjector.FindChild(_window, "StatusBarContainer") as FrameworkElement; _panel = _statusBar.Parent as DockPanel; }