You will have to give x:Name
to Image
and in setter set TargetName
to the image name given. It should work.
How to change the background image in button control template in wpf
-
26-06-2022 - |
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 ?
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow