title: WPF - IsEnabled Binding to DependencyProperty not working properly
body: <p>I have a dependency property defined in my window as below:</p>
  
  <pre><code>public static readonly DependencyProperty IsGenericUserProperty = DependencyProperty.Register("IsGenericUser", typeof (bool), typeof (MainWindow));
  public bool IsGenericUser
  {
      get { return (bool) GetValue(IsGenericUserProperty); }
      set { SetValue(IsGenericUserProperty, value); }
  }
  </code></pre>
  
  <p>On my window's constructor I set the data context of the container holding the button:</p>
  
  <pre><code>QuickListButtonsStackPanel.DataContext = this;
  </code></pre>
  
  <p>I am binding the dependency property to the IsEnabled property of a button:</p>
  
  <pre><code>&lt;Button IsEnabled="{Binding IsGenericUser}" .../&gt;
  </code></pre>
  
  <p>At startup IsGenericUser is true, so the button is enabled. When I set IsGenericUser to false, the button gets disabled. However, if I make IsGenericUser true again, nothing happens to the button and it remains disabled. 
  What am I doing wrong?</p>
  
  <p>Thanks!</p>
  
  <p>edit:
  Here is the style I am using with the button. This style is causing the issue (if the button has no custom style it works fine):</p>
  
  <pre><code>&lt;Style x:Key="BlackButtonStyle" TargetType="{x:Type Button}"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type Button}"&gt;
                  &lt;ControlTemplate.Resources&gt;
                      &lt;Storyboard x:Key="MouseOverActivating"&gt;
                          &lt;ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)"&gt;
                              &lt;SplineColorKeyFrame KeyTime="00:00:00" Value="#FF2F2F2F"/&gt;
                              &lt;SplineColorKeyFrame KeyTime="00:00:00.1270000" Value="#FF2391FF"/&gt;
                          &lt;/ColorAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                      &lt;Storyboard x:Key="MouseOverDeactivating"&gt;
                          &lt;ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="rectangle"&gt;
                              &lt;SplineColorKeyFrame KeyTime="00:00:00" Value="#FF2391FF"/&gt;
                              &lt;SplineColorKeyFrame KeyTime="00:00:00.2200000" Value="#FF2F2F2F"/&gt;
  
                          &lt;/ColorAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                      &lt;Storyboard x:Key="PressActivating"&gt;
                          &lt;ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)"&gt;
                              &lt;SplineColorKeyFrame KeyTime="00:00:00" Value="#FF2391FF"/&gt;
                              &lt;SplineColorKeyFrame KeyTime="00:00:00.1370000" Value="#FF48D6FF"/&gt;
                          &lt;/ColorAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                      &lt;Storyboard x:Key="PressedDeactivating" FillBehavior="Stop" &gt;
                          &lt;ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="rectangle"&gt;
                              &lt;SplineColorKeyFrame KeyTime="00:00:00" Value="#FF48D6FF"/&gt;
                              &lt;SplineColorKeyFrame KeyTime="00:00:00.2370000" Value="#FF2391FF"/&gt;
                          &lt;/ColorAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                      &lt;Storyboard x:Key="DisableActivating"&gt;
                          &lt;ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)"&gt;
                              &lt;SplineColorKeyFrame KeyTime="00:00:00" Value="#FFA7A7A7"/&gt;
                          &lt;/ColorAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                  &lt;/ControlTemplate.Resources&gt;
                  &lt;Grid&gt;
                      &lt;Rectangle Stroke="Transparent" RadiusX="5" RadiusY="5" x:Name="rectangle"&gt;
                          &lt;Rectangle.Fill&gt;
                              &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                                  &lt;GradientStop Color="#FF000000" Offset="0"/&gt;
                                  &lt;GradientStop Color="#FF2F2F2F" Offset="1"/&gt;
                              &lt;/LinearGradientBrush&gt;
                          &lt;/Rectangle.Fill&gt;
                      &lt;/Rectangle&gt;
                      &lt;ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True" OpacityMask="{x:Null}"/&gt;
                      &lt;Rectangle Stroke="Transparent" RadiusX="5" RadiusY="5" x:Name="WhiteGlow"&gt;
                          &lt;Rectangle.Fill&gt;
                              &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                                  &lt;GradientStop Color="#5BFFFFFF" Offset="0"/&gt;
                                  &lt;GradientStop Color="#00FFFFFF" Offset="0.5"/&gt;
                              &lt;/LinearGradientBrush&gt;
                          &lt;/Rectangle.Fill&gt;
                      &lt;/Rectangle&gt;
                  &lt;/Grid&gt;
                  &lt;ControlTemplate.Triggers&gt;
                      &lt;Trigger Property="IsCancel" Value="False"/&gt;
                      &lt;EventTrigger RoutedEvent="FrameworkElement.Loaded"/&gt;
                      &lt;Trigger Property="IsFocused" Value="True"&gt;
                          &lt;Trigger.ExitActions&gt;
                              &lt;BeginStoryboard Storyboard="{StaticResource MouseOverActivating}" x:Name="MouseOverActivating_BeginStoryboard2"/&gt;
                          &lt;/Trigger.ExitActions&gt;
                          &lt;Trigger.EnterActions&gt;
                              &lt;BeginStoryboard Storyboard="{StaticResource MouseOverActivating}" x:Name="MouseOverActivating_BeginStoryboard1"/&gt;
                          &lt;/Trigger.EnterActions&gt;
                      &lt;/Trigger&gt;
                      &lt;Trigger Property="IsDefaulted" Value="True"/&gt;
                      &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                          &lt;Trigger.ExitActions&gt;
                              &lt;BeginStoryboard Storyboard="{StaticResource MouseOverDeactivating}" x:Name="MouseOverDeactivating_BeginStoryboard"/&gt;
                          &lt;/Trigger.ExitActions&gt;
                          &lt;Trigger.EnterActions&gt;
                              &lt;BeginStoryboard Storyboard="{StaticResource MouseOverActivating}" x:Name="MouseOverActivating_BeginStoryboard"/&gt;
                          &lt;/Trigger.EnterActions&gt;
                      &lt;/Trigger&gt;
                      &lt;Trigger Property="IsPressed" Value="True"&gt;
                          &lt;Trigger.EnterActions&gt;
                              &lt;BeginStoryboard x:Name="PressActivating_BeginStoryboard" Storyboard="{StaticResource PressActivating}"/&gt;
                          &lt;/Trigger.EnterActions&gt;
                          &lt;Trigger.ExitActions&gt;
                              &lt;BeginStoryboard x:Name="PressedDeactivating_BeginStoryboard" Storyboard="{StaticResource PressedDeactivating}"/&gt;
                          &lt;/Trigger.ExitActions&gt;
                      &lt;/Trigger&gt;
                      &lt;Trigger Property="IsEnabled" Value="False"&gt;
                          &lt;Trigger.EnterActions&gt;
                              &lt;BeginStoryboard Storyboard="{StaticResource DisableActivating}" x:Name="DisableActivating_BeginStoryboard"/&gt;
                          &lt;/Trigger.EnterActions&gt;
                      &lt;/Trigger&gt;
                  &lt;/ControlTemplate.Triggers&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>