title: Style Trigger on Attached Property
body: <p>I have created my own Attached Property like this:</p>
  
  <pre><code> public static class LabelExtension
      {
          public static bool GetSelectable(DependencyObject obj)
          {
              return (bool)obj.GetValue(SelectableProperty);
          }
          public static void SetSelectable(DependencyObject obj, bool value)
          {
              obj.SetValue(SelectableProperty, value);
          }
          // Using a DependencyProperty as the backing store for Selectable.  This enables animation, styling, binding, etc...
          public static readonly DependencyProperty SelectableProperty =
              DependencyProperty.RegisterAttached("Selectable", typeof(bool), typeof(Label), new UIPropertyMetadata(false));
      }
  </code></pre>
  
  <p>And then I'm trying to create a style with a trigger that depends on it:</p>
  
  <pre><code>&lt;!--Label--&gt;
  &lt;Style TargetType="{x:Type Label}"&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="Util:LabelExtension.Selectable" Value="True"&gt;
              &lt;Setter Property="Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType="{x:Type Label}"&gt;
                          &lt;TextBox IsReadOnly="True" Text="{TemplateBinding Content}" /&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>But I'm getting a run time exception: </p>
  
  <pre><code>Cannot convert the value in attribute 'Property' to object of type 'System.Windows.DependencyProperty'.  Error at object 'System.Windows.Trigger' in markup file 
  </code></pre>
  
  <p>How can I access the value of the attached property in a style trigger? I have tried using a DataTrigger with a RelativeSource binding but it wasn't pulling the value through.</p>