2017-03-13 4 views
0

Wie kann die Navigation in einer UWP Template 10 App abgebrochen werden? Wir versuchen, die Navigation abzubrechen, wenn im ViewModel noch nicht gespeicherte Daten (IsDirty) vorhanden sind.Abbrechen der Navigation in UWP Template10

public class ViewModel : ViewModelBase 
{ 
    public override async Task OnNavigatingFromAsync(NavigatingEventArgs args) 
    { 
     if (this.IsDirty) 
     { 
      ContentDialog errorDialog = new ContentDialog(); 
      errorDialog.Title = "Save?"; 
      errorDialog.Content = "If you continue you will lose unsaved changes"; 
      errorDialog.PrimaryButtonText = "Cancel"; 
      errorDialog.SecondaryButtonText = "Continue"; 
      ContentDialogResult answer = await errorDialog.ShowAsync(); 
      if (answer == ContentDialogResult.Primary) 
       args.Cancel = true; 
     } 
     await Task.CompletedTask; 
    } 

Die Navigation wird jedoch nicht abgebrochen. Die Navigation kann abgebrochen werden, wenn der Dialog nicht angezeigt wird. Wie kann die Navigation in Reaktion auf einen Dialog vom ViewModel entfernt werden?

+0

Welche Version von T10 verwenden Sie? –

+0

@ Tibth Tibor Template10 1.1.12 – Vague

+0

@ Toth Tibor project.json zeigt Template10 1.1.12. Visual Studio Extension Manager zeigt Vorlage 10 Version 1.19. – Vague

Antwort

Verwandte Themen