Set Grid Column/Row width/Height dynamically
You could specify it like this:
For auto sized columns:
GridLength.Auto
For star sized columns:
new GridLength(1,GridUnitType.Star)
There is 3 types of setting Width to Grid ColumnDefinitions:
For Percentage Column:
yourGrid.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);
In xaml:
<ColumnDefinition Width="1*"/>
For Pixel Column
yourGrid.ColumnDefinitions[0].Width = new GridLength(10, GridUnitType.Pixel);yourGrid.ColumnDefinitions[0].Width = new GridLength(10);
In xaml:
<ColumnDefinition Width="10"/>
For Auto Column
yourGrid.ColumnDefinitions[0].Width = GridLength.Auto;
In xaml:
<ColumnDefinition Width="Auto"/>
Hope it helps!
I think this can help:
for Auto Column:
ColumnDefinition cd = new ColumnDefinition();cd.Width = GridLength.Auto;
or for proportion grid length:
ColumnDefinition cd = new ColumnDefinition();cd.Width = new GridLength(1, GridUnitType.Star);
or look at:http://msdn.microsoft.com/en-us/library/system.windows.gridlength.aspxandhttp://msdn.microsoft.com/en-us/library/system.windows.gridunittype.aspx
GreezShounbourgh