#476 – Set ZIndex Values for Child Elements of Canvas
January 19, 2012 Leave a comment
By default, child elements of a Canvas panel will be arranged in the order that they appear in a XAML file, with later elements appearing on top of earlier elements.
You can override this behavior by specifying explicit values for the Canvas.ZIndex attached property. An element with a higher ZIndex value will appear on top of an element with a lower value.
<Canvas Name="canv" Grid.Row="0">
<Button Content="1 - Lft10,Top10" Canvas.Left="10" Canvas.Top="10" Canvas.ZIndex="4"/>
<Button Content="2 - Rt10,Top10" Canvas.Right="10" Canvas.Top="15" Canvas.ZIndex="3"/>
<Button Content="3 - Lft10,Bott10..." Canvas.Left="15" Canvas.Bottom="15" Canvas.ZIndex="2"/>
<Button Content="4 - Rt10,Bott10" Canvas.Right="10" Canvas.Bottom="8" Canvas.ZIndex="1"/>
</Canvas>

