【问题标题】:Cancel Navigation in UWP Template10在 UWP Template10 中取消导航
【发布时间】:2017-03-13 08:15:12
【问题描述】:

如何在 UWP Template 10 应用中取消导航?我们正在尝试取消 ViewModel 中存在未保存数据 (IsDirty) 的导航。

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;
    }

但是导航没有取消。如果我们省略对话框,可以取消导航。如何取消导航离开 ViewModel 以响应对话框?

【问题讨论】:

  • 你用的是哪个版本的T10?
  • @Tóth Tibor Template10 1.1.12
  • @Tóth Tibor project.json 显示 Template10 1.1.12。 Visual Studio 扩展管理器显示模板 10 版本 1.19。

标签: uwp template10


【解决方案1】:

有人和你有同样的问题。 https://github.com/Windows-XAML/Template10/issues/1307

在 1.1.13(预览版)版本中已解决。所以你需要更新nuget包。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 2019-04-28
    相关资源
    最近更新 更多