Logo 
Search:

WPF Articles

Submit Article
Home » Articles » WPF » XAMLRSS Feeds

Grid Layout in XAML

Posted By: Vivek Patel     Category: WPF     Views: 42338

This article will explain Grid Layout in XAML. A very simple tutorial to understand Grid Layout in XAML.

Understanding Grid Layout in Xaml

  • Grid Layout Lays out element in multi-row and multi-column format.
  • It is conceptually similar to an HTML Table element.
  • It is most flexible and commonly used layout.

Grid Properties

  • Grid.RowDefinitions - It is used to define rows in grid layout.
  • Grid.ColumnDefinitions - It is used to define columns in grid layout.

Example of Grid Layout

<Grid>

    <Grid.RowDefinitions>
        <RowDefinition Height="60"/>
        <RowDefinition Height="40"/>
        <RowDefinition Height="40"/>
        <RowDefinition Height="40"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="60"/>
        <ColumnDefinition Width="60"/>
        <ColumnDefinition Width="60"/>
        <ColumnDefinition Width="60"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Label Content="Grid Layout Demo" 
                FontSize="15" FontWeight="Bold"
                Foreground="Blue"
                Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="5"/>

    <Label Content="Label1" FontSize="15" FontWeight="Bold" 
                Grid.Column="0" Grid.Row="1"/>

    <Label Content="Label2" FontSize="15" FontWeight="Bold"
                Grid.Column="1" Grid.Row="2"/>

    <Label Content="Label3" FontSize="15" FontWeight="Bold" 
                Grid.Column="2" Grid.Row="3"/>

    <Label Content="Label4" FontSize="15" FontWeight="Bold" 
                Grid.Column="3" Grid.Row="3"/>
</Grid>

Design View

Output
  
Share: 

 
 

Didn't find what you were looking for? Find more on Grid Layout in XAML Or get search suggestion and latest updates.

Vivek Patel
Vivek Patel author of Grid Layout in XAML is from United States. Vivek Patel says

I have started working in .Net Technology since its beta release and lucky to got chance to work on .Net 1.1, 2.0 and now working on .Net 3.5. I have worked in both C# and VB.Net for Asp.net Projects. I can also provide Sharepoint development needs. I can efficiently switch role from Tech Lead and Developer. I have comprehensive knowledge of Asp.net Development. I have been award Microsoft Most Valuable Award twice in Asp.net Technology.

Blog: http://dotnetguts.blogspot.com

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!