如果我有 2 Button
s, A
and B
,是否可以创建 aStyle
和 aTrigger
这样当用户将鼠标悬停在 时Button B
,它会导致Button A
'sStyle
改变?我尝试使用SourceName
and TargetName
,但出现编译器错误。这是我正在玩弄的 XAML - 我想让Button A
' 的内容在Button B
鼠标悬停时加粗:
<Window x:Class="WpfApplication1.Window4"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window4" Height="300" Width="300">
<Window.Resources>
<Style x:Key="BoldWhenOver" TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<Button Name="btnA" Content="A" Style="{StaticResource BoldWhenOver}" />
<Button Name="btnB" Content="B" />
</StackPanel>