Instead of changing the way selecting an item works, you could pass the current item as a command parameter to the command if you set the ContextMenu
property of each individual DataRow
:
<xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource RecordsForList}}" SelectedItem="{Binding SelectedRecord}">
<xcdg:DataGridControl.ItemContainerStyle>
<Style TargetType="xcdg:DataRow">
<Setter Property="Tag" Value="{Binding DataContext, RelativeSource={RelativeSource AncestorType=xcdg:DataGridControl}}" />
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Command="{Binding PlacementTarget.Tag.OpenCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
CommandParameter="{Binding}" Header="Open" />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
</xcdg:DataGridControl.ItemContainerStyle>
</xcdg:DataGridControl>
The other option would be to write some code in the view that actually selects an item on right-click, e.g.:
<xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource RecordsForList}}" SelectedItem="{Binding SelectedRecord}">
<xcdg:DataGridControl.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding OpenCommand}" Header="Open" />
</ContextMenu>
</xcdg:DataGridControl.ContextMenu>
<xcdg:DataGridControl.ItemContainerStyle>
<Style TargetType="xcdg:DataRow">
<EventSetter Event="PreviewMouseRightButtonDown" Handler="xgrid_PreviewMouseRightButtonDown" />
</Style>
</xcdg:DataGridControl.ItemContainerStyle>
</xcdg:DataGridControl>
private void xgrid_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
Xceed.Wpf.DataGrid.DataRow row = sender as Xceed.Wpf.DataGrid.DataRow;
xgrid.CurrentItem = row.DataContext;
}