What I am trying to do is a on/off togglebutton, and because I am using images as resources my main idea is to put one image as a normal ON state, another for mouseover ON and a third for a pressed ON state. The same goes for the OFF state, and all of it in one button. I did exactly the same with normal buttons, but here I am met with something I don't know: Doing an IF condition in xaml with all the triggers, which I have no idea where to even start. I read something about multitriggers but that seems complicated - any easier way to do this? This is what I did so far.
<ToggleButton IsChecked="False" Height="70" Width="70" >
<ToggleButton.Background>
<ImageBrush ImageSource="Resources\off_button_1.png" Stretch="None" />
</ToggleButton.Background>
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}" >
<StackPanel Orientation="Horizontal">
<Image x:Name="image" Source="Resources\off_button_1.png" Margin="0" Stretch="None" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="image" Property="Source" Value="Resources/off_button_1_hover.png" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="image" Property="Source" Value="Resources/off_button_1_pressed.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
</ToggleButton>
I'd really use some help here, thank you in advance.
You can create a custom button.
}
and here is the XAML ControlTemplate