<Image Source="Data\Images\close_nohover.bmp">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Source" Value="Data\Images\close_hover.bmp" />
</Trigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
答案 0 :(得分:3)
由于触发器更改了Source属性,因此必须在Style中设置Source,而不是在Image上显式设置。喜欢这个
<Image>
<Image.Style>
<Style TargetType="{x:Type Image}">
<Setter Property="Source" Value="Data\Images\close_nohover.bmp"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Source" Value="Data\Images\close_hover.bmp" />
</Trigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>