Reputation: 41
I have some problem with double click and sorting in datagrid.
When I double clicked on the header with enabled row my sorting is broke. I attempted filtering double click, but I have failure, this is a code, but dependencyObject is not always has name "DataGridHeaderBorder", and I dont know why?
private void dataGrid1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DependencyObject dependencyObject = (DependencyObject)e.OriginalSource;
if (dependencyObject.DependencyObjectType.Name != "DataGridHeaderBorder")
{
Edit_Task_MenuItem(sender, (RoutedEventArgs)e);
}
}
Upvotes: 0
Views: 291
Reputation: 184356
e.OriginalSource
is the very first object on which the routed event is fired, it may be the TextBlock
containing the header text or any other element inside the header. The sender
on the other hand would be the object on which the event handler is attached.
Upvotes: 1