title: Binding DataGrid Column DataTemplate to Attached Property
body: <p>I am trying to customize a <i>DataGridColumnHeader</i> to show multiple text fields instead of<br>
  showing only the header text provided by <i>DataGridColumn.Header</i> property.<br>
  If i didn't miss something, i just have to create a <i>DataTemplate</i> and bind to the properties<br>
  of the parent object. This works fine for the <i>DataGridColumn.Header</i> property but<br>
  binding to attached property fails. </p>
  
  <p>For the sake of completeness, implementation of the attached property:</p>
  
  <pre><code>public static class CustomHeader
  {
      public static string GetUnit(DependencyObject obj) { return (string)obj.GetValue(UnitProperty); }
      public static void SetUnit(DependencyObject obj, string value) { obj.SetValue(UnitProperty, value); }
  
      public static readonly DependencyProperty UnitProperty = DependencyProperty.RegisterAttached(
          "Unit", typeof(string), typeof(CustomHeader), new FrameworkPropertyMetadata(null));
  }
  </code></pre>
  
  <p>Usage in the Xaml-Markup:  </p>
  
  <pre><code>&lt;DataGrid x:Name="tObjectDataGrid" Margin="10,50,10,10" 
                    AutoGenerateColumns="False" EnableRowVirtualization="True"  
                    ItemsSource="{Binding ObjectList}"  
                    RowDetailsVisibilityMode="VisibleWhenSelected" &gt;
    &lt;DataGrid.Resources&gt;  
      &lt;DataTemplate x:Key="CustomHeaderTemplate"&gt;  
        &lt;StackPanel&gt;  
          &lt;TextBlock Text="{Binding}" /&gt;  
          &lt;TextBlock Text="{Binding Path=(cust:CustomHeader.Unit)}" /&gt; &lt;-- attached binding doesn't work :( 
        &lt;/StackPanel&gt;  
      &lt;/DataTemplate&gt;  
    &lt;/DataGrid.Resources&gt;  
  
    &lt;DataGrid.Columns&gt;  
      &lt;DataGridTextColumn x:Name="SpeedColumn"
                          Width="1*"
                          Binding="{Binding Speed}"
                          Header="Speed"
                          HeaderTemplate="{StaticResource CustomHeaderTemplate}"
                          cust:CustomHeader.Unit="[m/s]" /&gt;  
    &lt;/DataGrid.Columns&gt;  
  &lt;/DataGrid&gt;  
  </code></pre>
  
  <p>I really appreciate any comment or weblink that clarifies what i am missing here.
  Thanks in advance.</p>