我希望当鼠标悬停在按钮/文本块上时文本块的前景会发生变化。我已经尝试过了,但这不起作用:
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Header}"/>
<Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
Margin="5,-3,0, 0"
Visibility="{Binding IsCloseButtonVisible}"
Command="{Binding CloseSelectedTabCommand}">
<Button.Content>
<TextBlock Text="x" Foreground="LightGray">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Button.Content>
</Button>
</StackPanel>
</DataTemplate>