如果属性设置为值,我想禁用行选择
我尝试过:
<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>
我不想禁用整个DataGrid,因为水平滚动不再可滚动了,所以我避免了这一点。
答案 0 :(得分:1)
如果要取消选择整个行,请尝试使用RowStyle
并将数据触发器为true时将属性IsSelected
设置为false:
<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>