private void Button_EditAddressClick(object sender, RoutedEventArgs e) { AddressItem addressItem = _addressBookViewModel.AddressItems[addressListView.SelectedIndex]; AddressItem addressItemOld = new AddressItem { Name = addressItem.Name, EMailAdress = addressItem.EMailAdress, IsSelected = addressItem.IsSelected, }; AddressItemWindow addressItemWindow = new AddressItemWindow { Owner = this, AddressItem = addressItem, }; if (addressItemWindow.ShowDialog() == true) { _addressBookViewModel.AddressItems[addressListView.SelectedIndex] = addressItemWindow.AddressItem; } else { _addressBookViewModel.AddressItems[addressListView.SelectedIndex] = addressItemOld; } _addressBookViewModel.Save(); }
void AddressItemWindow_Loaded(object sender, RoutedEventArgs e) { if (AddressItem == null) AddressItem = new AddressItem(); DataContext = AddressItem; }