Friday, November 21, 2008

Silverlight 3, WPF Positioning with ZIndex

You can use ZIndex property to change the order in which controls are rendered on a canvas.













The control with highest ZIndex value will be shown at the very top. Here Blue rectangle is having ZIndex 3, Yellow having ZIndex 2, so Blue rectanle will appear at the very top, followed by Yellow rectange and Cyan rectangle.

Programatically changing the ZIndex

private void Button_Click(object sender, RoutedEventArgs e)
{
Canvas.SetZIndex(rectCyan, 4);
}

No comments:

Post a Comment