I have a context menu set up on the xamDataGrid. When I right click I would like the Records that I right clicked on to be the one and only SelectedItem.
Thanks,
Rod
void xamDataGrid1_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
DependencyObject source = e.OriginalSource as DependencyObject; if (source == null) return; DataRecordPresenter drp = Infragistics.Windows.Utilities.GetAncestorFromType(source, typeof(DataRecordPresenter), true) as DataRecordPresenter; if (drp == null) return; if (drp.Record != null) { drp.Record.IsSelected = true; drp.IsActive = tru; }
DependencyObject source = e.OriginalSource as DependencyObject;
if (source == null)
return;
DataRecordPresenter drp = Infragistics.Windows.Utilities.GetAncestorFromType(source, typeof(DataRecordPresenter), true) as DataRecordPresenter;
if (drp == null)
if (drp.Record != null)
{ drp.Record.IsSelected = true; drp.IsActive = tru; }
drp.Record.IsSelected = true; drp.IsActive = tru;
drp.Record.IsSelected = true;
drp.IsActive = tru;
}
Do you have any good suggestions on how to make this support multiple-record selection. I was trying to capture key events to try and track the user holding down CTRL/SHIFT to determine if the selected records should be cleared on the mouse click but the key events don't seem to be triggered. I also tried the preview key events.
Thanks!
-Tammy
Excellent! Thanks Joe.