Grid


GridHierarchy: UIElement FrameworkElement Panel

 <Grid ShowGridLines="true|false" /> 

<Grid .../> is similar to a Table but is more flexible than its traditional counterpart. Grid allows layering of content, including multiple elements in a single cell, whereas Table does not. Child elements in a Grid can be absolutely positioned relative to the upper-left corner of their cell boundaries. Finally, child elements are added to Grid based on row and column index, while child elements in a Table are declared within its parent cell.

Grid is a container for ColumnDefinition, RowDefinition, and elements that are placed by specifying their desired row and column attributes.

An example of a Grid with content follows and is evaluated in XamlPad in Figure 10-3:

     <Grid ShowGridLines="true">         <ColumnDefinition Width="100"/>         <ColumnDefinition Width="100"/>         <RowDefinition Height="100" />         <RowDefinition Height="25" />         <RowDefinition Height="25" />         <TextBlock Grid.Column="0" Grid.Row="0">Col 0, Row 0</TextBlock>         <TextBlock Grid.Column="1" Grid.Row="0">Col 1, Row 0</TextBlock>         <TextBlock Grid.Column="0" Grid.Row="1">Col 0, Row 1</TextBlock>         <TextBlock Grid.Column="1" Grid.Row="1">Col 1, Row 1</TextBlock>         <TextBlock Grid.Column="0" Grid.Row="2">Col 0, Row 2</TextBlock>         <TextBlock Grid.Column="1" Grid.Row="2">Col 1, Row 2</TextBlock>     </Grid> 

Figure 10-3. Grid with content and ShowGridLines=true


Attributes


ShowGridLines (optional)

This attribute determines whether the grid will be lined.


true

The gridlines will be displayed.


false

No gridlines will be displayed.

Attached Attributes


Grid.Column

A zero-based integer representing the column of the Grid into which the element should be placed


Grid.Row

A zero-based integer representing the row of the Grid into which the element should be placed




XAML in a Nutshell
XAML in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596526733
EAN: 2147483647
Year: 2007
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net