using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using WPFProject.Controls; namespace WPFProject.Utils { public class CanvasHelper { public static void SetTopZIndex(InnerWindow element, DependencyObject parent, Type targetClass) { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) { InnerWindow child = VisualTreeHelper.GetChild(parent, i) as InnerWindow; if (child != null && targetClass == child.GetType()) { if (element == child) { child.Zindex = 1; } else { child.Zindex = 0; } } } } } }