我想为当前拥有焦点的DataGrid行设置边框,但不是选定的行,因为当启用DataGrid的多重选择时,可能会选择多个行。
我需要一个XAML解决方案。
提前感谢!
我想为当前拥有焦点的DataGrid行设置边框,但不是选定的行,因为当启用DataGrid的多重选择时,可能会选择多个行。
我需要一个XAML解决方案。
提前感谢!
DataGridRow
的样式中(可以使用资源或通过设置 DataGrid.RowStyle
实现):<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsFocused" Value="true">
<Setter Property="BorderBrush" Value="Red" />
<Setter Property="BorderThickness" Value="1" />
</Trigger>
</Style.Triggers>
</Style>
IsSelected
属性而不是 IsFocused
属性会起作用? - Dan J尝试使用IsKeyboardFocusWithin属性
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin"
Value="True">
<Setter Property="BorderBrush"
Value="Red" />
</Trigger>
</Style.Triggers>