我有一个带有ControlTemplate和Triggers的样式,如下所示:
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Border x:Name="DGR_Border">
<SelectiveScrollingGrid>
<SelectiveScrollingGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</SelectiveScrollingGrid.ColumnDefinitions>
<SelectiveScrollingGrid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</SelectiveScrollingGrid.RowDefinitions>
<DataGridCellsPresenter x:Name="DGR_CellsPresenter"
Grid.Column="1" />
<DataGridDetailsPresenter x:Name="DGR_DetailsPresenter"
Grid.Row="1"
Grid.Column="1"/>
<DataGridRowHeader x:Name="DGR_Header"
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="0"/>
</SelectiveScrollingGrid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True" />
<Condition Property="Selector.IsSelectionActive" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="Magenta" />
<Setter TargetName="DGR_Border" Property="Background" Value="LavenderBlush" />
<Setter TargetName="DGR_Header" Property="Background" Value="LavenderBlush" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
如何在选择DataGridRow时设置前景,但DataGrid未聚焦。无论我尝试什么,它都行不通!