WPF Button on or off coloured state

Posted by wonea on Stack Overflow See other posts from Stack Overflow or by wonea
Published on 2010-05-21T14:46:45Z Indexed on 2010/05/21 15:00 UTC
Read the original article Hit count: 154

Filed under:
|
|

I'm trying to create a set of button which have an off or on state, much a checkbox without the check. Ideally I want the colour to change to represent the two different states off(red), green(on). I've tried setting a control template but this only changes the colour for a selection, then reverts back to it's original colour once the mouse leaves the button's vicinity.

<ControlTemplate.Triggers>
   <Trigger Property="IsPressed" Value="True">
      <Setter Property="Background" TargetName="Background" Value="Green"/>
   </Trigger>
</ControlTemplate.Triggers>

© Stack Overflow or respective owner

Related posts about wpf

Related posts about c#