Monday, June 11, 2012

Grid Row and Column Definition in Silverlight


In Silverlight you can create table like we do in HTML. For that you have to use GRID control(layout) of Silverlight. Under GRID it has got two Attached Depenedency properties

1. Grid.RowDefinitions
2.Grid.ColumnDdefinitions

<Grid>
    <Grid.RowDefinitions>
         <RowDefinition />/*By default all the space available for Grid will divided into 4 rows if you dont specify any height for any row.*/
         <RowDefinition />
         <RowDefinition />
         <RowDefinition />
    </Grid.RowDefinitions>
</Grid>

1. If you set Height="Auto"- This means height of row will depend on the content on that particular row. If you have a control lets say Listbox which is in Grid.Row=1 and on row 1 you have set RowHeight="Auto". So the height of that row will be dependent on Listbox height. If listbox height is 0 then row 1 will not take any space and all the space available for that grid will be available for rest of rows fo that particular Grid.

2.If you set Height="*"-- This means this row will get all the remaining space of the Grid . If there are more than one rows with height as "*" then the remaining height will be distributed between them. If there is any number with "*" that means that is the distribution factor.

3. If you set Height="50"- This means this will set row height to 50 in all the cases.

The same theory applies to Grid.ColumnDefinitions as well . If you have any query/suggest send me email  admin@exploresilverlight.com

Regards
Vinod

No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog