Search code examples
c#wpfeventsdatagridtoolkit

Set different SelectionChanged Event Handler for a DataGrid inside another DataGrid


I have a DataGrid (WPF Toolkit) with a custom combobox like edit template of a cell. This custom combo box have another datagrid like popup.

I have this problem:

In the window constructor I assign the event handler to the master datagrid with this statement

this.dgDoc.SelectionChanged += new SelectionChangedEventHandler(dgDoc_SelectionChanged);

the problem is that the function dgDoc_SelectionChanged fire also when I change selection on datagrid of combobox popup.

How can I avoid this behavior?


Solution

  • the events are bubbling up the tree and are finding a handler. bummer.

    why dont you just check who the sender is and if it is the inner grid, ignore them, if it is the grid you are interested in handle them