2

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

2 Answers 2

1

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);
}
Sign up to request clarification or add additional context in comments.

1 Comment

Very nice, but how do I get the row index aswell when clicking the row header?
0

Or if you are manipulating the RowHeaderStyle, then,

        <Setter Property="RowHeaderStyle">
            <Setter.Value>
                <Style TargetType="{x:Type DataGridRowHeader}">
                    <EventSetter Event="PreviewMouseDown"
                                 Handler="OnGridRowHeaderClick" />
                </Style>
            </Setter.Value>
        </Setter>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.