开发者

Change Image OnMouseOver in ControlTemplate

Here is my XAML:

<Style x:Key="ExpanderStyle" TargetType="{x:Type ToggleButton}">
    <Setter Property="IsEnabled" Value="True" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Image Source="/Images/SHCalendarLeftArrow.tiff" />
            </ControlTemplate>
        </Setter.Value>
    &开发者_StackOverflowlt;/Setter>
</Style>

So how can I add a Trigger to that OnMouseOver the image in the ControlTemplate changes to a different image.


Try using a Trigger inside your template:

<Setter Property="Template"> 
    <Setter.Value> 
        <ControlTemplate> 
            <Image x:Name="PART_img" Source="/Images/SHCalendarLeftArrow.tiff" /> 

            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter TargetName="PART_img"
                            Property="Source"
                            Value="/Images/SomeOtherImage.tiff" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate> 
    </Setter.Value> 
</Setter> 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜