CurrentCell property of the DataGrid needs to be bound to the view model instead of SelectedItem. Mode is set to one way so when the selection is changed, the property in the viewmodel is updated.
<datagrid itemssource="{Binding Products}" currentcell="{Binding CurrentCell, Mode=OneWayToSource}">
</datagrid>
private CurrentCellInfo _currentcell;
public CurrentCellInfo CurrentCell
{
get {return _currentcell;}
set
{
if (value.Column != null && value != _currentcell)
{
_currentcell = value;
_selectedproduct = (Product)_currentcell.Item;
}
}
}
All that is left is to get the value of whatever properties from _selectedproduct