How do i get right mouse click to add active record to SelectedItems collection without removing currently selected records?
This is what I currently have but records are being unselected on right mouse click:
void OnGridMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
DataRecordPresenter drp = sender as DataRecordPresenter;
if (drp != null)
if (drp.DataPresenter != null
&& drp.DataPresenter.SelectedItems != null
&& drp.DataPresenter.SelectedItems.Records != null)
drp.DataPresenter.SelectedItems.Records.Add(drp.Record);
}
TIA.
You can use the PreviewMouseRightButtonDown event and the following code to obtain the DataRecordPresenter:
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings SelectionTypeRecord="Single"/>
</igDP:XamDataGrid.FieldLayoutSettings>
private 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 = true;
Hope this helps!
Vlad, thanks for response.
Your proposed solution selects the current active record upon mouse right click, which is good. However, it does not solve the problem where currently selected items are unselected upon mouse right click.