Grid Layout in Silverlight

No.of Views875
Bookmarked0 times
Downloads 
Votes0
By  lokeshbasana   On  16 Feb 2010 00:02:19
Tag : Silver Light and XAML , How to
Grid Layout in Silverlight
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction


The grid is a layout control is a container of other silverlight controls. Grid acts like Html table, it places other silverlight controls like Textbox, Checkbox, and Button …

I am going to create 2 rows and 6 columns using Grid layout control


{codecitation class="brush: xml; gutter: true;" width="700px"}

<UserControl xmlns:controls=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit”  x:Class=”ExpanderControl.grid”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Width=”400″ Height=”400″>
<Grid x:Name=”LayoutRoot” Background=”White” ShowGridLines=”True”  >
<Grid.RowDefinitions>
<RowDefinition Height=”30″></RowDefinition>
<RowDefinition Height=”30″></RowDefinition>
<RowDefinition Height=”30″></RowDefinition>
<RowDefinition Height=”30″></RowDefinition>
<RowDefinition Height=”30″></RowDefinition>
<RowDefinition Height=”30″></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=”200″></ColumnDefinition>
<ColumnDefinition Width=”200″></ColumnDefinition>
</Grid.ColumnDefinitions>
<controls:Label x:Name=”lblr0c0″   Content=”User Registration” Grid.Row=”0″ Grid.Column=”0″ Margin =”-40,5,5,5″ Grid.ColumnSpan=”2″ HorizontalAlignment=”Center” ></controls:Label>
<controls:Label x:Name=”lblr1c0″   Content=”FirstName” Grid.Row=”1″ Grid.Column=”0″ Margin =”100,5,5,5″ ></controls:Label>
<controls:Label x:Name=”lblr1c1″   Content=”Text” Grid.Row=”1″ Grid.Column=”1″ Margin =”10,5,5,5″ ></controls:Label>
<controls:Label x:Name=”lblr2c0″   Content=”LastName” Grid.Row=”2″ Grid.Column=”0″ Margin =”100,5,5,5″ ></controls:Label>
<controls:Label x:Name=”lblr2c1″   Content=”Text” Grid.Row=”2″ Grid.Column=”1″ Margin =”10,5,5,5″ ></controls:Label>
<controls:Label x:Name=”lblr3c0″   Content=”DOB” Grid.Row=”3″ Grid.Column=”0″ Margin =”100,5,5,5″ ></controls:Label>
<controls:Label x:Name=”lblr3c1″   Content=”Text” Grid.Row=”3″ Grid.Column=”1″ Margin =”10,5,5,5″ ></controls:Label>
<controls:Label x:Name=”lblr4c0″   Content=”Gender” Grid.Row=”4″ Grid.Column=”0″ Margin =”100,5,5,5″ ></controls:Label>
<controls:Label x:Name=”lblr4c1″   Content=”Text” Grid.Row=”4″ Grid.Column=”1″ Margin =”10,5,5,5″ ></controls:Label>
<Button x:Name=”btnTest” Width=”150″ Content=”Register” Grid.Row=”5″ Grid.ColumnSpan=”2″></Button>
</Grid>
</UserControl>


{/codecitation}


Margin: A value measured by pixels that specifies a uniform Thickness. The uniform value is applied to all four Thickness properties (Left, Top, Right, Bottom).

EX: Margin =”100,5,5,5″


Grid.Colspan will span the columns used in User Registration Title

HorizontalAlignment: alignment of the row

Ex: HorizontalAlignment=”Center”

Output

Image Loading....

Thank you
Lokesh
http://lokesh.wordpress.com

 
Sign Up to vote for this article
 
About Author
 
lokeshbasana
Occupation-Not Provided
Company-Not Provided
Member Type-Fresh
Location-Not Provided
Joined date-13 Jul 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top