I would like to have an image button for my Wpf application. At first i was happy with this answer i've found (WPF Button with Image).
However, now i want to make a style/template out of it, so i don't need to write the same thing over and over again.
The closest i could get was this image:
Image showing the three buttons i got so far
The problem is: I've lost the background (seems like there's nothing!). I already tried to get the background back with a Rectangle, but then, the button has no animations - there's no mouse over or click different colors. Seems like by using a template i erased it all...
That's not what i wanted to. I wanted to simply set a template and have all the default colors/animations.
This is my XAML so far:
<Style x:Key="btnSave" TargetType="{x:Type Button}">
<Setter Property="Width" Value="100"></Setter>
<Setter Property="Height" Value="25"></Setter>
<Setter Property="Margin" Value="5"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<StackPanel Orientation="Horizontal">
<Image Source="/Resources/save.png"></Image>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
What i wanted was to simply use it as:
<Button Style="{StaticResource btnSave}">Save File</Button>
And have a button with an image and default colors/animations.
Is there a simple way to do this? I don't want to mess with Triggers so far, all the links i've found about this try to teach how to make a full custom button.