I have a DataGrid with the DataContext as a list of objects with many properties.
All of the columns are bound to a different property of said object type.
There is a text property that I only care about if another bool property is set to "true" - when it is "false" I don't want the text property to show at all.
Do you have any way to suggest doing this?
I was thinking of something along the lines of:
foreach (var cur in DG.ItemsSource) {
if (!cur.BoolThatSignifiesIfICareAboutOtherProperty) {
//some code that will make the cell for cur.PropertyIMayOrMayNotCareAbout
//appear empty even though that property does have a value that the column
//is bound to
}
}
** edit **
It was suggested that I use a data trigger. So this is what I tried, but it also doesn't work. Nor does it give any errors, so I don't know what I'm doing wrong.
Here is what I have so far. It doesn't work, though. Please let me know what I'm doing wrong:
<DataGridTextColumn Header="EndDate" Binding="{Binding Path=EndDate, Converter={StaticResource DT2D}}">
<DataGridTextColumn.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DoICare}" Value="False">
<Setter Property="Content" Value=" " />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>