alielie
2025-05-20 99df058a665ea04065a23e729ec79a2f23f79881
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Windows;
using System.Windows.Media;
 
namespace Plugin.TestBuilder.UI
{
    public class CanvasHelper
    {
        public static void SetTopZIndex(InnerWindow element, DependencyObject parent, Type targetClass)
        {
            int max = 0;
            int zindex = element.Zindex;
 
            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 >= zindex)
                    {
                        child.Zindex = child.Zindex-1;
                    }
                   
                }
                max++;
            }
            element.Zindex = max;
        }
    }
}