Creating rows and columns in grid using XAML

Creating new columns and rows is done using the ColumnDefinitions and RowDefintions properties on a grid. This allows you to specify that individual elements are in a particular row or column using the attached property.

<UserControl x:Class="silverlight.Sample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition />
      <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <TextBlock Text="Hello" Grid.Column="1" />
  </Grid>
</UserControl>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.