i try to change the column width after a click on a button.
I am learning MVVM pattern and I want to avoid code behind.
I am able to initilaize the width at 0 but i am not succeed to change the width at runtime.
i show you a copy of my code.
Hope you can help me !
thanks a lot guy
cheers Cyrille
MainView.xaml
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="{Binding NotamWidth}"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
MainViewModel for binding the width and to initialize the column width at 0
//Propoerty for column width
public GridLength NotamWidth { get; set; }
public AirportViewModel()
{
//initialize width of column at 0
MainGridModel MainGridModel = new MainGridModel(new GridLength(0));
this.NotamWidth = MainGridModel.NotamWidth;
}
MainGridModel which support property for the grid
private GridLength notamWidth;
public MainGridModel(GridLength width)
{
NotamWidth = width;
}
public GridLength NotamWidth
{
get
{
return notamWidth;
}
set {
notamWidth = value;
}
}
RelayCommand for changing the column width
public void ShowNotamExecute(object parameter)
{
//Masque la colonne notam
this.NotamWidth = new GridLength(400);
}