title: WPF trigger on attached property not working
body: <p>i'm trying to change an image which i put as button's content through an attached property, yet for some reason the image is not changing and i don't get any exceptions or anything solid in the output.
  Here is my attached property class code:</p>
  
  <pre><code>public class ImageButton
  </code></pre>
  
  <p>{
          #region Image dependency property</p>
  
  <pre><code>    /// &lt;summary&gt;
      /// An attached dependency property which provides an
      /// &lt;see cref="ImageSource" /&gt; for arbitrary WPF elements.
      /// &lt;/summary&gt;
      public static DependencyProperty ImageProperty;
  
      /// &lt;summary&gt;
      /// Gets the &lt;see cref="ImageProperty"/&gt; for a given
      /// &lt;see cref="DependencyObject"/&gt;, which provides an
      /// &lt;see cref="ImageSource" /&gt; for arbitrary WPF elements.
      /// &lt;/summary&gt;
      public static ImageSource GetImage(DependencyObject obj)
      {
          return (ImageSource)obj.GetValue(ImageProperty);
      }
  
      /// &lt;summary&gt;
      /// Sets the attached &lt;see cref="ImageProperty"/&gt; for a given
      /// &lt;see cref="DependencyObject"/&gt;, which provides an
      /// &lt;see cref="ImageSource" /&gt; for arbitrary WPF elements.
      /// &lt;/summary&gt;
      public static void SetImage(DependencyObject obj, ImageSource value)
      {
          obj.SetValue(ImageProperty, value);
      }
  
      #endregion
  
  static ImageButton()
      {
          //register attached dependency property
          var metadataImage = new FrameworkPropertyMetadata((ImageSource)null);
          ImageProperty = DependencyProperty.RegisterAttached("Image",
                                                              typeof(ImageSource),
                                                              typeof(ImageButton), metadataImage);
      }
  </code></pre>
  
  <p>}</p>
  
  <p>here the code for the style using the attached property(the image source is set to take the value):</p>
  
  <pre><code>&lt;Style TargetType="{x:Type Button}" x:Key="MyImageButton"&gt;
      &lt;Setter Property="Background" Value="White"/&gt;
      &lt;Setter Property="SnapsToDevicePixels" Value="True" /&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type Button}"&gt;
                  &lt;Border
                      x:Name="Border"
                      Background="White"&gt;
                      &lt;ContentPresenter&gt;
                          &lt;ContentPresenter.Content&gt;
                              &lt;Grid
                                  x:Name="Grid"
                                  Background="White"&gt;
                                  &lt;Grid.ColumnDefinitions&gt;
                                      &lt;ColumnDefinition Width="Auto"/&gt;
                                      &lt;ColumnDefinition Width="Auto"/&gt;
                                  &lt;/Grid.ColumnDefinitions&gt;
                                  &lt;Image
                                       Grid.Column="0"
                                      Source="{Binding Path=(attachedProperties:ImageButton.Image),
                                                       RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Button}}}"
                                      Width="30"
                                      Height="25"
                                      Margin="5,0,2,0"
                                      VerticalAlignment="Center"/&gt;
                                  &lt;TextBlock
                                      x:Name="TextBlock"
                                      Grid.Column="1"
                                      Text="{Binding Path=(attachedProperties:ImageButton.StringContent),
                                                     RelativeSource={RelativeSource     Mode=FindAncestor,AncestorType={x:Type Button}}}"
                                      VerticalAlignment="Center"
                                      TextAlignment="Center"
                                      Margin="0,0,15,0"/&gt;
                              &lt;/Grid&gt;
                          &lt;/ContentPresenter.Content&gt;
                      &lt;/ContentPresenter&gt;
                  &lt;/Border&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>and finally the XAML code using the style and the trigger there trying to change the image source:</p>
  
  <pre><code>&lt;Button
      Grid.Row="2"
      Width="30"
      attachedProperties:ImageButton.Image="..\Images\Down_Arrow_Enabled_Icon_25x25.png"
      Command="{Binding PriorityDownCommand}"&gt;
      &lt;Button.Style&gt;
         &lt;Style TargetType="{x:Type Button}"
                BasedOn="{StaticResource MyImageButton}"&gt;
                  &lt;Style.Triggers&gt;
                      &lt;Trigger Property="IsEnabled" Value="False"&gt;
                          &lt;Setter Property="attachedProperties:ImageButton.Image" Value="..\Images\Down_Arrow_Disabled_Icon_25x25.png"/&gt;
                      &lt;/Trigger&gt;
                  &lt;/Style.Triggers&gt;
         &lt;/Style&gt;
      &lt;/Button.Style&gt;
  </code></pre>
  
  <p></p>
  
  <p>thanks ahead for anyone who can find the problem!!!</p>