Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Set grid column width with IsStar from code behind.
3 replies. Latest Post by baskarg83 on August 11, 2009.
(0)
xkrja
Member
67 points
136 Posts
08-11-2009 3:49 AM |
How can I set the width of a column in a grid to be 50% of the total grid width? In XAML the '*' is used but I don't understand how to set that property from code behind. Any ideas?
Thanks for help!
ssenthil
501 points
108 Posts
08-11-2009 4:07 AM |
gridLayout.ColumnDefinitons[1].Width = double.NaN;
08-11-2009 7:50 AM |
No. Did you try this?
gridLayout.ColumnDefinitons[1].Width
is of type 'GridLength' not double.
Other ideas anyone?
baskarg83
414 points
127 Posts
08-11-2009 8:10 AM |
Try this code
MyGrid.ColumnDefinitions[0].Width = new GridLength(0.28, GridUnitType.Star);MyGrid.ColumnDefinitions[1].Width = new GridLength(.72, GridUnitType.Star);
i hope this will help u, mark as answer