views:

22

answers:

1

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>
            </Setter>
        </Style>

So how can I add a trigger to that OnMouseOver the image in the controltemplate changes to a different image.

+1  A: 

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> 
Matt Hamilton