I want to programmatically configure a wpf grid.
I want to be able to set a grid with 2 columns, the first taking up 20% of available space, the second taking up 80
View (XAML)
ViewModel (C#)
public class MyViewModel : BindableBase
{
private GridLength _firstColumn;
private GridLength _secondColumn;
public MyViewModel()
{
_firstColumn = new GridLength(75, GridUnitType.Star);
_secondColumn = new GridLength(25, GridUnitType.Star);
}
public GridLength FirstColumn
{
get { return _firstColumn; }
set { SetProperty(ref _firstColumn, value); }
}
public GridLength SecondColumn
{
get { return _secondColumn; }
set { SetProperty(ref _secondColumn, value); }
}
private void NotifyToggleFullScreen(bool isToggleExpansion)
{
if (isToggleExpansion)
{
FirstColumn = new GridLength(0, GridUnitType.Auto);
SecondColumn = new GridLength(100, GridUnitType.Star);
}
else
{
FirstColumn = new GridLength(75, GridUnitType.Star);
SecondColumn = new GridLength(25, GridUnitType.Star);
}
}
}