Search code examples
wpfz-index

WPF ZIndex from more parents


If i have 2 canvases, one with ZIndex 1 and one with ZIndex 2.

The Canvas with ZIndex 1 has 2 children: 2 canvases, one with ZIndex 4 and one with ZIndex 6.

The Canvas with ZIndex 2 has 2 children: 2 canvases, one with ZIndex 3 and one with ZIndex 5.

And all these canvases has the same dimension and the same starting point, so i will see a single rectangle.

What will be the final order of drawing? 1,2,3,4,5,6 or 1,4,6,2,3,5?

In other words every parent will draw its children based on the ZIndex (so first the parent with ZIndex 1 and after that the parent with ZIndex 2? Or the ZIndex works at global level?


Solution

  • The Canvas with a ZIndex of 2 will end up on top of the first one and the child Canvas with a ZIndex of 5 will be the visible one.

    So a child Canvas of the Canvas with a ZIndex of 1 will not end up on top of a child Canvas of the Canvas with a ZIndex of 2.