...
Code Block |
---|
/// <summary> /// Gets the AddPerson command. /// </summary> public Command AddPerson { get; private set; } /// <summary> /// Method to invoke when the AddPerson command is executed. /// </summary> private async void OnAddPersonExecute() { var person = new Person(); person.LastName = FamilyName; // Note that we use the type factory here because it will automatically take care of any dependencies // that the PersonViewModel will add in the future var typeFactory = this.GetTypeFactory(); var personViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion<PersonViewModel>(person); if (await _uiVisualizerService.ShowDialogShowDialogAsync(personViewModel) ?? false) { Persons.Add(person); } } /// <summary> /// Gets the EditPerson command. /// </summary> public Command EditPerson { get; private set; } /// <summary> /// Method to check whether the EditPerson command can be executed. /// </summary> /// <returns><c>true</c> if the command can be executed; otherwise <c>false</c></returns> private bool OnEditPersonCanExecute() { return SelectedPerson != null; } /// <summary> /// Method to invoke when the EditPerson command is executed. /// </summary> private async void OnEditPersonExecute() { // Note that we use the type factory here because it will automatically take care of any dependencies // that the PersonViewModel will add in the future var typeFactory = this.GetTypeFactory(); var personViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion<PersonViewModel>(SelectedPerson); await _uiVisualizerService.ShowDialogShowDialogAsync(personViewModel); } /// <summary> /// Gets the RemovePerson command. /// </summary> public Command RemovePerson { get; private set; } /// <summary> /// Method to check whether the RemovePerson command can be executed. /// </summary> /// <returns><c>true</c> if the command can be executed; otherwise <c>false</c></returns> private bool OnRemovePersonCanExecute() { return SelectedPerson != null; } /// <summary> /// Method to invoke when the RemovePerson command is executed. /// </summary> private async void OnRemovePersonExecute() { if (await _messageService.Show(string.Format("Are you sure you want to delete the person '{0}'?", SelectedPerson), "Are you sure?", MessageButton.YesNo, MessageImage.Question) == MessageResult.Yes) { Persons.Remove(SelectedPerson); SelectedPerson = null; } } |
...
Code Block |
---|
/// <summary> /// Gets the AddFamily command. /// </summary> public Command AddFamily { get; private set; } /// <summary> /// Method to invoke when the AddFamily command is executed. /// </summary> private async void OnAddFamilyExecute() { var family = new Family(); // Note that we use the type factory here because it will automatically take care of any dependencies // that the FamilyWindowViewModel will add in the future var typeFactory = this.GetTypeFactory(); var familyWindowViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion<FamilyWindowViewModel>(family); if (await _uiVisualizerService.ShowDialog(familyWindowViewModel) ?? false) { Families.Add(family); } } /// <summary> /// Gets the EditFamily command. /// </summary> public Command EditFamily { get; private set; } /// <summary> /// Method to check whether the EditFamily command can be executed. /// </summary> /// <returns><c>true</c> if the command can be executed; otherwise <c>false</c></returns> private bool OnEditFamilyCanExecute() { return SelectedFamily != null; } /// <summary> /// Method to invoke when the EditFamily command is executed. /// </summary> private async void OnEditFamilyExecute() { // Note that we use the type factory here because it will automatically take care of any dependencies // that the PersonViewModel will add in the future var typeFactory = this.GetTypeFactory(); var familyWindowViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion<FamilyWindowViewModel>(SelectedFamily); await _uiVisualizerService.ShowDialogShowDialogAsync(familyWindowViewModel); } /// <summary> /// Gets the RemoveFamily command. /// </summary> public Command RemoveFamily { get; private set; } /// <summary> /// Method to check whether the RemoveFamily command can be executed. /// </summary> /// <returns><c>true</c> if the command can be executed; otherwise <c>false</c></returns> private bool OnRemoveFamilyCanExecute() { return SelectedFamily != null; } /// <summary> /// Method to invoke when the RemoveFamily command is executed. /// </summary> private async void OnRemoveFamilyExecute() { if (await _messageService.Show(string.Format("Are you sure you want to delete the family '{0}'?", SelectedFamily), "Are you sure?", MessageButton.YesNo, MessageImage.Question) == MessageResult.Yes) { Families.Remove(SelectedFamily); SelectedFamily = null; } } |
...