开发者

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜