How do I select a record on right click?
Hello,
I have been looking into your issue and can suggest you 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)
{
(sender as DataRecordPresenter).Record.IsSelected = true;
}
Please let me know if you require any further assistance or clarification on the matter.
Sincerely,
Petar Monov
Developer Support Engineer
Infragistics Bulgaria
www.infragistics.com/support
Thanks but for some reason, I am not getting this event fired. Should there be another line of code to add this style to the datagrid?
It worked when I added the style to the datagrid resource. Thanks for the quick answer.
<igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:DataRecordPresenter}"> <EventSetter Event="MouseRightButtonDown" Handler="DataRecordPresenter_MouseRightButtonDown" /> </Style></igDP:XamDataGrid.Resources>
Can we have the same event to fired via ViewModel.
Something similar to EventToCommand ? can you give me syntax on it or sample?