Hi,
I need the following functionality:
on 1 click on label - sort
on double click - some other functionality.
I set LabelClickAction="Sort"
and also implemented the following:
EventManager.RegisterClassHandler(typeof(LabelPresenter), LabelPresenter.MouseDoubleClickEvent, new RoutedEventHandler(onHeaderDoubleClick));
When I double click on the label I see the following:
the field is sorted twice and the MouseDoubleClickEvent is fired.
Question: how can I prevent the double-sorting when I double-click on the label? Isn't there some kind of time interval that helps to distinguish between fast 2 separate clicks and one double-click?
Thanks
Hello,
You should be going for the PreviewMouseDoubleClick event instead of the MouseDoubleClick.
The XamDataGrid will handle any bubbling event with its logic that's why you have to use the tunneling equivalents.
For more information about tunneling and bubbling events and differences between them you can look in the msdn.
Thanks Alex.
I did what yous said, but it worked only for the first double-click. On the following double-clicks again: 2 separate single-clicks occur and than 1 double-click.
Looking at it again more closely, you are absolutely right.
Because it is a Double Click event, the MouseLeftButtonDown will fire as well and before the DoubleClick. This is why you are seeing the sorting. Having in mind that you have the CellClickAction to Sort and the MouseLeftButtonDown event fired before DoubleClick, I see no way of cancelling the sorting when double-clicking because the sorting occurs before the double click.
One way around this would be to set the CellClickAction to Nothing and handle sorting manually (adding FieldSortDescriptions in the SortedFields collection of the FieldLayout).