Why does this Trigger not fire?
<Image Source="Data\Images\close_nohover.bmp">
&l开发者_JAVA技巧t;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>
Since the trigger changes the Source Property, the Source must be set within the Style and not explicitly on the Image. Like this
<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>
精彩评论