[WPF] uses the XAML Trigger system to implement three-state buttons, wpfxaml
Using the WPF Trigger system, you can also simply use xmal to implement three-state buttons. Declare the style of the button in the Window or UserControl resource and add the trigger function. You can simply re-write the style in the button when using it. If you don't talk much about it, simply add the Code:
<UserControl.Resources> <Style x:Key="threeStateButton" TargetType="{x:Type Button}"> <Setter Property="SnapsToDevicePixels" Value="True"/> <Setter Property="OverridesDefaultStyle" Value="True"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <StackPanel Orientation="Horizontal" > <Image Name="ImgBtnBg3" Source="Skins/Default/action_normal.png" /> </StackPanel> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Source" Value="Skins/Default/action_selected.png" TargetName="ImgBtnBg3"/> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Source" Value="Skins/Default/action_active.png" TargetName="ImgBtnBg3"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Source" Value="Skins/Default/action_normal.png" TargetName="ImgBtnBg3"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources>
Reference in button for use:
<Button x: Name = "m_btn" Content = "Button" HorizontalAlignment = "Center" Width = "60" Height = "60"
VerticalAlignment = "Center" Style = "{StaticResource threeStateButton}"/>