private void Edit_Contact(object sender, MouseButtonEventArgs e) { try { DataGrid dg = sender as DataGrid; DonorContactGrid p = (DonorContactGrid)dg.SelectedItems[0]; // OR: Patient p = (Patient)dg.SelectedItem; UpdateContact up = new UpdateContact(p); up.DeleteCon.IsEnabled = false; up.ShowDialog(); } catch (Exception error) { } Refresh_ContactsGrid(sender, e); }