I\'m having a DataGrid to list the MobileInfo Collection. The DataGrid is Configured with SelectionUnit=\"FullRow\"
. If I Click the any Row then it selects the
You could bind the command parameter to DataGrid.CurrentCell property. There are several ways to accomplish that, one of which is specifying relative source for the binding:
<KeyBinding Key="C"
Modifiers="Control"
Command="{Binding CopyToClipBoardCommand}"
CommandParameter="{Binding CurrentCell, RelativeSource={RelativeSource FindAncestor, AncestorType=DataGrid}}" />
Note that I removed the DataContext.
part from the command binding path (DataContext
is the default source for binding if source is not explicitly specified).
The command parameter will now be an object of type DataGridCellInfo, which is a structure, and not a class.
You can modify the command parameter binding path to extract more specific info.
you can simply use CurrentCellChanged Event in DataGrid xaml.
CurrentCellChanged="DataGrid_CurrentCellChanged"
code...
private void DataGrid_CurrentCellChanged(object sender, EventArgs e)
{
var grid = sender as DataGrid;
var cell = grid.CurrentCell.Item;
}