Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I am trying to figure a way to change the current image on mouseover.
I am using the following code but it doesn't work.

<Button x:Name="AnswerButton"   Grid.Column="0" VerticalAlignment="Center" HorizontalContentAlignment="Center" Width="60" Height="60" Background="Transparent" IsEnabled="False" Click="AnswerButton_OnClick" BorderBrush="Transparent" BorderThickness="0">
                   <Image Source="/VeriPark.CTI.Demo;component/Images/Answer.PNG" Stretch="UniformToFill"/>
               </Button>


<Style TargetType="{x:Type Image}">
          <Setter Property="Source" Value="/VeriPark.CTI.Demo;component/Images/Answer.PNG"/>
          <Style.Triggers>
              <Trigger Property="IsMouseOver" Value="True">
                  <Setter Property="Source" Value="/VeriPark.CTI.Demo;component/Images/answer-hover.PNG"/>
              </Trigger>
          </Style.Triggers>
      </Style>


What I have tried:

Tried google and no luck, searched in different sites
Posted
Updated 24-Sep-18 10:24am

1 solution

You should set the style for the button instead,
and set the content property in the trigger

<Style TargetType="{x:Type Button}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Content" >
                    <Setter.Value>
                        <Image Source="/VeriPark.CTI.Demo;component/Images/answer-hover.PNG" Stretch="UniformToFill"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>


===================================================
If that works for you, please mark it as an answer.
 
Share this answer
 
Comments
Faran Saleem 25-Sep-18 6:59am    
It doesn't work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900