You are on page 1of 1

Grid, Element Order, and Z Order

You might be wondering why the Grid doesn't simply put items into the grid in th
e order in which they
appearthis would remove the need for the Grid.Row and Grid.Column attached proper
ties. There are a
couple of reasons why it doesn't work this way.
Grid cells can be empty. If the grid's children simply filled the cells in order
, you would need to put
placeholders of some kind to indicate blank cells. But since elements indicate t
heir grid position, you can
leave cells empty simply by providing no content for that cell.
Cells can also contain multiple elements. In this case, the order in which the r
elevant elements are listed in
the markup determines which appears "on top." Elements that appear later in the
document are drawn over
those that appear earlier. The order in which overlapping elements are drawn is
usually referred to as the Z
order . This is because the x- and y-axes are traditionally the ones used for dr
awing onscreen, so the z-axis
would logically be used to determine how overlapping elements are ordered.
In general, panels that allow their children to overlap (e.g., Grid and Canvas)
rely on the order in which
elements appear in the XAML to determine the Z order.

You might also like