title: WPF ToggleButton state is reset to normal and not checked state after mouseover
body: <p>I have made an extension of the ToggleButton. It inherits from ToggleButton and I have addad some dependency properties. I want the label and text to highligt on mouse over and when IsChecked is true. </p>
  
  <p>Desiered outcome</p>
  
  <ul>
  <li>Normal state: Dark text</li>
  <li>MouseOver: Light text </li>
  <li>Checked: Light text</li>
  </ul>
  
  <p>It works fine when in normal state and on mouse over. When i toggle the button it is still highlighted when i remove the mouse from it. But when i hover again the text goes back to dark like it is not checked. What am I doing wrong? (If I remove mouseover state the text is still highlighted when toggeled) Is it because mouseover and checked is in different visualstategroups?</p>
  
  <p>Here is my code in generic.xaml</p>
  
  <pre><code>&lt;Style TargetType="{x:Type view:ExtendedToggleButton}"&gt;
      &lt;Setter Property="BorderThickness" Value="1" /&gt;
      &lt;Setter Property="BorderBrush" Value="{DynamicResource LineBrush}" /&gt;
      &lt;Setter Property="Padding" Value="5" /&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type view:ExtendedToggleButton}"&gt;
                  &lt;Grid&gt;
                      &lt;VisualStateManager.VisualStateGroups&gt;
                          &lt;VisualStateGroup x:Name="CommonStates"&gt;
                              &lt;VisualState x:Name="Normal"/&gt;
                              &lt;VisualState x:Name="MouseOver"&gt;
                                  &lt;Storyboard&gt;
                                      &lt;!--&lt;ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="{DynamicResource BackgroundMouseOverColor}"/&gt;--&gt;
                                      &lt;ColorAnimation Duration="0" Storyboard.TargetName="LabelControl" Storyboard.TargetProperty="(Label.Foreground).(SolidColorBrush.Color)" To="{DynamicResource TitleColor}"/&gt;
                                      &lt;ColorAnimation Duration="0" Storyboard.TargetName="TextControl" Storyboard.TargetProperty="(Label.Foreground).(SolidColorBrush.Color)" To="{DynamicResource DetailTextColor}"/&gt;
  
                                  &lt;/Storyboard&gt;
                              &lt;/VisualState&gt;
                              &lt;VisualState x:Name="Pressed"&gt;
                                  &lt;Storyboard&gt;
                                      &lt;ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="{DynamicResource BackgroundMousePressedColor}"/&gt;
                                  &lt;/Storyboard&gt;
                              &lt;/VisualState&gt;
                              &lt;VisualState x:Name="Disabled"&gt;
                                  &lt;Storyboard&gt;
                                      &lt;DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" To=".55"/&gt;
                                  &lt;/Storyboard&gt;
                              &lt;/VisualState&gt;
                          &lt;/VisualStateGroup&gt;
                          &lt;VisualStateGroup x:Name="CheckStates"&gt;
                              &lt;VisualState x:Name="Checked"&gt;
                                  &lt;Storyboard&gt;
                                      &lt;ColorAnimation Duration="0" Storyboard.TargetName="LabelControl" Storyboard.TargetProperty="(Label.Foreground).(SolidColorBrush.Color)" To="{DynamicResource TitleColor}"/&gt;
                                      &lt;ColorAnimation Duration="0" Storyboard.TargetName="TextControl" Storyboard.TargetProperty="(Label.Foreground).(SolidColorBrush.Color)" To="{DynamicResource DetailTextColor}"/&gt;
  
                                  &lt;/Storyboard&gt;
                              &lt;/VisualState&gt;
                              &lt;VisualState x:Name="Unchecked"/&gt;
                          &lt;/VisualStateGroup&gt;
                          &lt;VisualStateGroup x:Name="FocusStates"&gt;
                              &lt;VisualState x:Name="Focused" /&gt;
                              &lt;VisualState x:Name="Unfocused" /&gt;
                          &lt;/VisualStateGroup&gt;
                      &lt;/VisualStateManager.VisualStateGroups&gt;
                      &lt;Border x:Name="Background" Background="Transparent" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"&gt;
                          &lt;Grid Background="{TemplateBinding Background}"  Margin="1"&gt;
  
                          &lt;/Grid&gt;
                      &lt;/Border&gt;
                      &lt;StackPanel&gt;
                          &lt;WrapPanel Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"&gt;
                              &lt;TextBlock x:Name="LabelControl" Margin="0 0 10 0" FontSize="14" Foreground="{DynamicResource DescreteTitleBrush}" Text="{TemplateBinding Label}" /&gt;
                              &lt;TextBlock x:Name="TextControl" Margin="5 2 0 0" FontSize="12" Foreground="{DynamicResource DarkDetailTextBrush}" TextWrapping="Wrap" Text="{TemplateBinding Text}" /&gt;
                          &lt;/WrapPanel&gt;
                          &lt;ContentPresenter 
                                    x:Name="contentPresenter"
                                    Content="{TemplateBinding Content}"
                                    ContentTemplate="{TemplateBinding ContentTemplate}"/&gt;
                      &lt;/StackPanel&gt;
                      &lt;Rectangle x:Name="DisabledVisualElement" Fill="#FFFFFFFF" Opacity="0" IsHitTestVisible="false" /&gt;
                  &lt;/Grid&gt;
  
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>I have tried adding triggers to the ControlTemplate, but it does not help.</p>
  
  <pre><code>&lt;ControlTemplate.Triggers&gt;
      &lt;Trigger Property="IsChecked" Value="True"&gt;
          &lt;Setter TargetName="LabelControl" Property="Foreground" Value="{DynamicResource TitleBrush}" /&gt;
      &lt;/Trigger&gt;
  &lt;/ControlTemplate.Triggers&gt;
  </code></pre>