Frage

I wanted to change the background image on mouse over. But i could n't. below is my source code..

    <Button.Template>
    <ControlTemplate>
          <Border HorizontalAlignment="Center" VerticalAlignment="Center">
            <Image Source="../Resources/Images/refresh.png"   Width="16" Height="16" />
           </Border>
    </ControlTemplate>
     </Button.Template>

I tried with below code but it is not even compiling..

       <ControlTemplate.Triggers>
           <Trigger Property="IsMouseOver" Value="True">
              <Setter Property="Source" Value="../Resources/Images/refresh_Hover.png"                            />
           </Trigger>
        </ControlTemplate.Triggers>

Any help ?

War es hilfreich?

Lösung

You will have to give x:Name to Image and in setter set TargetName to the image name given. It should work.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top