With WPF's Trigger system, you can also simply implement a tri-state button using only xmal. Declare the style of the button in the Resource of window or UserControl and add the trigger function. Use the time directly in the button to make a copy of the style can be, nonsense not much to say, directly on the code:
<UserControl.Resources> <style x:key= "Threestatebutton" targettype= "{x:type button}" > <se Tter property= "Snapstodevicepixels" value= "true"/> <setter property= "Overridesdefaultstyle" Value= "true"/ > <setter property= "Template" > <Setter.Value> <controltempl Ate 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" Targetnam E= "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= "I MgBtnBg3 "/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </style> ; </UserControl.Resources>
Referenced in the button when used:
<button x:name= "m_btn" content= "button" horizontalalignment= "Center" width= "All" height= "60"
Verticalalignment= "Center" style= "{StaticResource Threestatebutton}"/>
WPF uses the Trigger system of XAML to implement a tri-state button