private void grGiaoVien_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (sender != null) { DataGridRow row = sender as DataGridRow; if (row != null) { var item = row.DataContext as GiaoVien; if (item != null) { var giaoVienInfo = new GiaoVienInfo(item); giaoVienInfo.ShowDialog(); } } } }
private void grGiaoVien_ShowInfo(object sender, RoutedEventArgs e) { var menuItem = (MenuItem)sender; var contextMenu = (ContextMenu)menuItem.Parent; var item = (DataGrid)contextMenu.PlacementTarget; var b = item.SelectedValue; if (b is GiaoVien) { var c = b as GiaoVien; var giaoVienInfo = new GiaoVienInfo(c); giaoVienInfo.ShowDialog(); } }