Z-Order of Controls RRS feed

  • Question

  • In winforms we used the Bringtofront and Sendtoback to position the Z related index of the controls


    Now in WPF.


    First there is a SetZIndex shared property that can be used to position a Control.


    Second when we use the SomeCanvasContainer.Children.Add() we add a Control at the end of the list (in front) and we are able to move this Control by using the Children.Insert(Index) . But they all have the same Zindex value.


    My Qs:

    How are these two Z order's related to each other and what would be the best solution to use when having a lot of controls loaded onto a canvas that should be able to reposition (Z order)?

    Wednesday, December 19, 2007 3:30 PM


  • Items with equal ZIndex are rendered in the order they are in the visual tree (i.e. their order in the Children collection). Items with higher ZIndex are rendered more to the foreground.


    Personally, i think moving things in the collection is better, because if you move it to the start or end of the collection, you dont need to worry about ZOrder values on other controls - it will go to the front or back.






    Wednesday, December 19, 2007 3:51 PM