title: ToggleButton changing image depending on state
body: <p>I would like to use ToggleButton in following way:
  There are 5 different images and each of them should be displayed depending on current state:</p>
  
  <ol>
  <li>button disabled</li>
  <li>button enabled, unchecked</li>
  <li>button enabled, unchecked, pointed by mouse cursor</li>
  <li>button enabled, checked</li>
  <li>button enabled, checked, pointed by mouse cursor</li>
  </ol>
  
  <p>I've found a simple example with two images <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/28c36bd2-2ef7-4232-9976-2a0967140e32" rel="noreferrer">here</a> , but how to change the image depending on "checked" property?</p>
  
  <p>The second question: how can I avoid creating different styles for each button in my application? I'm using about 20 different buttons and each of them has different set of icons.</p>
  
  <p>So far I'm using only one icon, below my code. Is it possible to have common code (style and template) and to define the source of images in section where I want to create button (like in section 3 of my code)?</p>
  
  <pre><code>&lt;ControlTemplate x:Key="ToggleButtonTemplate" TargetType="{x:Type ToggleButton}"&gt;
      &lt;Grid&gt;
          &lt;Border x:Name="ContentBorder" CornerRadius="4" BorderBrush="Transparent" BorderThickness="1" Background="{DynamicResource ButtonOff}"&gt;
              &lt;ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/&gt;
          &lt;/Border&gt;
      &lt;/Grid&gt;
      &lt;ControlTemplate.Triggers&gt;
          &lt;Trigger Property="IsPressed" Value="true"&gt;
              &lt;Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ButtonOn}"/&gt;
          &lt;/Trigger&gt;
          &lt;Trigger Property="IsChecked" Value="true"&gt;
              &lt;Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ButtonOn}"/&gt;
          &lt;/Trigger&gt;
          &lt;Trigger Property="IsEnabled" Value="false"&gt;
              &lt;Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ButtonDisabled}"/&gt;
              &lt;Setter Property="Foreground" Value="{DynamicResource BorderDisabled}"/&gt;
          &lt;/Trigger&gt;
      &lt;/ControlTemplate.Triggers&gt;
  &lt;/ControlTemplate&gt;
  
  &lt;Style x:Key="ToggleButtonStyle" TargetType="{x:Type ToggleButton}"&gt;
      &lt;Setter Property="Width" Value="64" /&gt;
      &lt;Setter Property="Height" Value="64" /&gt;
      &lt;Setter Property="HorizontalContentAlignment" Value="Center"/&gt;
      &lt;Setter Property="VerticalContentAlignment" Value="Center"/&gt;
      &lt;Setter Property="Template" Value="{DynamicResource ToggleButtonTemplate}" /&gt;
  &lt;/Style&gt;
  
  &lt;ToggleButton IsChecked="{Binding Path=IsLectorModeEnabled}" Command="{Binding CmdLector}" Style="{DynamicResource ToggleButtonStyle}"&gt;
      &lt;Image Source="{DynamicResource LectorImage}" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" /&gt;
  &lt;/ToggleButton&gt;
  </code></pre>