Search code examples
wpfeventsdatagriddatagridrowheader

Event on click the row header of a WPF DataGrid?


In my WPF-Project, I have a DataGrid. I want to get an Event when the user clicks on the RowHeader, but I cannot find one. Any ideas?

Thanks in advance,
Frank


Solution

  • I think you can handle OnLoadingRow of your dataGrid and set RowHeader. sth like this:

    protected override void OnLoadingRow(DataGridRowEventArgs e)
    {
        DataGridRow row = e.Row;
        if (e.Row.GetType() != typeof(DataGridRowHeader))
        {
            DataGridRowHeader header=new DataGridRowHeader();
            header.Click+=new System.Windows.RoutedEventHandler(header_Click);
            row.Header = header;
        }
         base.OnLoadingRow(e);
    }