Hi,
This is bit outdated question, but I want to handle GridviewRow double click event more efficiently.
My grid view contains RowDetails template (Tab control). Row details contains summary and attachment tab. While attachment tab displays attachments in girdview control.
I had registered GridviewRow double click event in parent GridView as
private void GridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
if (e.Row is GridViewRow)
{
e.Row.AddHandler(GridViewRow.MouseDoubleClickEvent, new MouseButtonEventHandler(OnRowMouseDoubleClick), false);
}
}
Double click event is fired as expected but with following exception (which is not required), but as per behavior its valid.
- Double click event triggered by double click on parent gridview header
- Double click event triggered by double click on GridviewRow details (even scroll bar in attachment gridview)
To overcome these I added following checks
private async void OnRowMouseDoubleClick(object sender, MouseButtonEventArgs args)
{
FrameworkElement originalSender = args.OriginalSource as FrameworkElement;
var cell = originalSender.ParentOfType<GridViewCell>();
if (cell == null)
{
return;
}
var selectedRowContext = ((System.Windows.FrameworkElement)sender).DataContext as MyDataContext;
if (selectedRowContext == null)
return;
}
Basically I am validating Gridview Header and RowDetails gridview scrollbar by "cell" in above example.
While I validate Row details double click by selectedRowContext as there datacontext is different from MyDataContext.
I feel that this is temporary solution. I want to fix it, i.e. double click only happens on DataRow or Data cell. All other controls in Gridview should be excluded.