I have a DataGrid
defined as follows :
<DataGrid Name="dtMydatagrid" Margin="10,10,10,10" RowHeight="20" AutoGenerateColumns="True" ItemsSource="{Binding}" Height="auto" Width="auto">
<DataGrid.Columns>
<DataGridTemplateColumn Header="">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox x:Name="TXT" Background="Transparent" Width="15" IsReadOnly="True" Visibility="Hidden" Margin="0,0,0,0"/>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=IsBKM}" Value="true">
<Setter Property="Background" Value="AQUA" TargetName="TXT"/>
<Setter Property="Visibility" Value="Visible" TargetName="TXT"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Now, I have a boolean property in my class named IsBKM
to which the DataGridTemplateColumn
is bounded.
So, it is displayed by as CheckBox
.
I don't want to display the IsBKM
column in my DataGrid
. Can I use a trigger and hide the column whose name is IsBKM
or any different solution?
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…