I have a WPF application containing a grid. The grid is split into 3 columns, and the 3rd grid has zero width when loading.
I have two datagrids in two other columns. When a selected item in one of the datagrid data changes other changes in the datagrid, it displays the values, i.e. Main part template. All of this works great.
There is one value in the datagrid which, if selected, I want this third column to change its width from zero to 2 *. I do not know how to do that?
I want to achieve this through XAML. I watched data triggers and value converters. I quickly wrote the code below to check. I read that setting the column to width = 0 is probably higher on the priority list of dependency properties. Anyway, to do this or will I need to use the code?
<Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="2*"/> <ColumnDefinition Width="0"/> </Grid.ColumnDefinitions> <DataGrid Grid.Column="0" ItemsSource="{Binding OrderList}" SelectedItem="{Binding OrderSelected}" AutoGenerateColumns="True"> </DataGrid> <TextBox Grid.Column="1" Text="{Binding OrderSelected.Name}"> </TextBox> <Grid x:Name="columnHideSeek" Grid.Column="2" Background="Blue"> <Grid.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding OrderSelected.Name}" Value="Mark"> <Setter Property="Grid.Width" Value="10"/> </DataTrigger> </Style.Triggers> </Style> </Grid.Style> </Grid> </Grid>
source share