我正在尝试IsSelectionActive
使用 WPF DataGrid:
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<ContentPresenter />
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelectionActive" Value="False" />
<Condition Property="IsSelected" Value="True" />
<!--<Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}}, Path=IsSelected}" Value="True" />
<Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=IsKeyboardFocusWithin}" Value="True" />-->
</MultiTrigger.Conditions>
基本上,当网格失去焦点,但选择仍然存在时,我想应用一些样式。
不幸的是,IsSelectionActive
由于某种原因,它会引发 WPF 数据网格中不存在的错误。