title: WPF Click event on dynamically generated column headers
body: <p>I have a ListView which contains a GridView. Its columns are dynamically generated with attached properties of the class "GridViewColumns" like this :</p>
  
  <pre><code>&lt;GridView 
                  ColumnHeaderTemplate="{StaticResource HeaderFilter}"
                  self:GridViewColumns.DisplayMemberMember="DisplayMember"
                  self:GridViewColumns.DisplayMemberFormatMember="DisplayMemberFormat"
                  self:GridViewColumns.WidthMember="Width"
                  self:GridViewColumns.HeaderTextMember="HeaderText"
                  self:GridViewColumns.ImageTemplateMember="{StaticResource ImageTemplate}"
                  self:GridViewColumns.ColumnsSource="{Binding WorkItemsColumns}"/&gt;
  </code></pre>
  
  <p>Example of definition in GridViewColumns.cs :</p>
  
  <pre><code>[AttachedPropertyBrowsableForType(typeof(GridView))]
      public static string GetHeaderTextMember(DependencyObject obj)
      {
          return (string)obj.GetValue(HeaderTextMemberProperty);
      }
  
      public static void SetHeaderTextMember(DependencyObject obj, string value)
      {
          obj.SetValue(HeaderTextMemberProperty, value);
      }
  
  
      public static readonly DependencyProperty HeaderTextMemberProperty =
          DependencyProperty.RegisterAttached("HeaderTextMember", typeof(string), typeof(GridViewColumns), new UIPropertyMetadata(null));
  </code></pre>
  
  <p>The template of the gridview headers :</p>
  
  <pre><code>            &lt;DataTemplate x:Key="HeaderFilter" DataType="GridViewColumnHeader"&gt;
                  &lt;StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"&gt;
                      &lt;Button Name="FilterButton" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Height="18" Margin="5,0,5,0"&gt;
                          &lt;Image Source="Wfl.Presentation.Tibco;component/Resources/Images/filter2.png" /&gt;
                      &lt;/Button&gt;
                      &lt;TextBlock x:Name="Entete" Text="{Binding}"  FontSize="14"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>How can I define the Click event on the headers of that GridView ?</p>