private void DGMaterials_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DataRowView row = (DataRowView)dGMaterials.SelectedItem;
MessageBox.Show(" ID: " + row["Id"]);
}
Не удалось привести тип объекта "DemoExam2018.ViewModel.OrderingMaterialsPageViewModel" к типу "System.Data.DataRowView
private void DGMaterials_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DataGrid grid = sender as DataGrid;
if (grid != null && grid.SelectedItems != null && grid.SelectedItems.Count == 1)
{
DataGridRow dgr = grid.ItemContainerGenerator.ContainerFromItem(grid.SelectedItem) as DataGridRow;
DataRowView row = (DataRowView)dgr.Item;
MessageBox.Show(" ID: " + row["Id"]);
}
}