0

In the XAML, I have this code

<igDP:FieldLayout.FieldSettings>
    <igDP:FieldSettings AllowRecordFiltering="True" CellClickAction="SelectRecord" AllowEdit="False"/>
</igDP:FieldLayout.FieldSettings>

Here, the CellClickAction is for the left click. Is there some corresponding Action for the right click as well to select the record. I want the record to be selected both on the left and the right click

Manan Shah
  • 367
  • 1
  • 7
  • 18

1 Answers1

1

create a Style for the DataRecordPresenter (the DataRecord’s visual element) with an EvenSetter like for the MouseRightButtonDown event like this one:

<Style TargetType="{x:Type igDP:DataRecordPresenter}">
    <EventSetter Event="MouseRightButtonDown" Handler="DataRecordPresenter_MouseRightButtonDown" />
</Style>

and use this code snippets in its event handler:

void DataRecordPresenter_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
    // Clear previous selcted rows        
    (sender as DataRecordPresenter).Record.IsSelected = true;
}

There is one problem here: if you continue right click on rows/cell in different row it selects multiple rows. So clear any previous selection then it will work.

Alexander Schmidt
  • 5,631
  • 4
  • 39
  • 79
WPFKK
  • 1,419
  • 3
  • 20
  • 42
  • The command to clear would be `dataGrid.ExecuteCommand(DataPresenterCommands.ClearAllSelected);` if `dataGrid` is the name of your grid control. – Alexander Schmidt May 17 '16 at 10:41