Export (0) Print
Expand All

Panel.SetZIndex Method

Sets the value of the ZIndex attached property for a given element.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

'Declaration
Public Shared Sub SetZIndex ( _
	element As UIElement, _
	value As Integer _
)

Parameters

element
Type: System.Windows.UIElement

The element on which to apply the property value.

value
Type: System.Int32

The order on the z-plane in which this element appears.

ExceptionCondition
ArgumentNullException

The element is Nothing.

The greater the value of a given element, the more likely the element is to appear in the foreground. Likewise, if an element has a relatively low value, the element will likely appear in the background. For example, an element that has a value of 5 will appear above an element that has a value of 4, which in turn will appear above an element that has a value of 3, and so on. Negative values are allowed, and they continue this precedence pattern.

Members of a Children collection that have equal ZIndex values are rendered in the order in which they appear in the visual tree. You can determine the index position of a child by iterating the members of the Children collection.

The following example demonstrates in code how to set the value of the ZIndex property (by using the SetZIndex method).

Canvas.SetTop(myRectangle2, 150)
Canvas.SetLeft(myRectangle2, 150)
Canvas.SetZIndex(myRectangle2, 1)
myRectangle2.Fill = Brushes.Yellow
myRectangle2.Width = 100
myRectangle2.Height = 100

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft