So I'm creating columns dynamically for a Grid layout in Silverlight (V3.0, C#):
LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
and you can specific that the width of the column be "auto" with
LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
But how to you set it to be "*" (share with with other columns)?
I know you can set this in the XAML, but how do you do it in code?
Pass a GridLength with a GridUnitType of Star:
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) };
Bonus is that this technique also supports proportional spacing i.e. the equivalent of XAML 2*, 3*, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With