WPF Datagrid ContextMenu SelectedItem
<p>I have the following problem.
I have a DataGrid with a ContextMenu. But when the Command is triggered the SelectedItem is always null. <br>Any recommendations?</p>

<p>Thats my ContextMenu: </p>

<pre><code>&lt;DataGrid.ContextMenu&gt;
  &lt;ContextMenu&gt;
  &lt;MenuItem Command="{Binding OpenFileCommand}"
           CommandParameter="{Binding Path=SelectedItem,
           RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
           Header="open file" /&gt;
</code></pre>

<p>
 </p>

<p>i also tried:
<code>CommandParameter="{Binding ElementName=nameOfGrid, Path=SelectedItem}"</code></p>