private void BtnEdit_Click(object sender, RoutedEventArgs e) { int pos = DataGrid.SelectedIndex; if (pos == -1) { MessageBox.Show("Seleccione un material", "Error"); return; } MyItem item; try { item = (MyItem)DataGrid.SelectedItem; } catch (InvalidCastException) { return; } ItemForm window = new ItemForm((MyItem)item.Clone(), pos); window.ShowDialog(); }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { ItemForm window = new ItemForm(); window.ShowDialog(); }