Reputation: 16764
I want to disable row selection if a property is set to a value
I tried:
<DataGrid ...>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsBusy}" Value="True">
<Setter Property="here I don't know" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
</DataGrid>
I don't want to disable entire DataGrid because horizontal scroll is not scrollable anymore, so I avoid this.
Upvotes: 2
Views: 130
Reputation: 15209
If you want to unselect the entire row, try with a RowStyle
instead and set the property IsSelected
to false when your your data trigger is true:
<DataGrid>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<Setter Property="Foreground" Value="Black" />
<DataTrigger Binding="{Binding Path=IsBusy}" Value="True">
<Setter Property="IsSelected" Value="False" />
</DataTrigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="Foreground" Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="Foreground" Value="Black" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="BorderBrush" Value="{x:Null}" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
</DataGrid>
Upvotes: 1