public AddressBookViewModel(AddressBook addressBook, Navigation navigation) { _addressBook = addressBook; _navigation = navigation; _summaries = new MappedObservableCollection<Person, PersonSummaryViewModel>( person => new PersonSummaryViewModel(person), _addressBook.People); _navigation.PropertyChanged += NavigationPropertyChanged; _newCommandObject = new CommandObject( () => { _navigation.SelectedPerson = _addressBook.NewPerson(); }); _deleteCommandObject = new CommandObject( () => _navigation.SelectedPerson != null, () => { if (_navigation.SelectedPerson != null) { _addressBook.DeletePerson(_navigation.SelectedPerson); _navigation.SelectedPerson = null; } }); }
private void MainPage_Loaded(object sender, RoutedEventArgs e) { AddressBook addressBook = new AddressBook(); Navigation navigation = new Navigation(); DataContext = new AddressBookViewModel(addressBook, navigation); addressBook.GetPeople(Dispatcher); }