操作暂停,恢复和激活窗口10 UWP [英] Handling suspend, resume, and activation in windows 10 UWP

查看:541
本文介绍了操作暂停,恢复和激活窗口10 UWP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 8.1中的普遍应用,挂起/恢复模式用处理的 NavigationHelper.cs SuspensionManager.cs 包含在APP模板类。这些类似乎并没有在那里在windows 10 UWP应用程序。有没有使我们能够处理挂起/恢复状态的方法是什么?

In the windows 8.1 universal apps, the suspend/resume modes were handled using the NavigationHelper.cs ans SuspensionManager.cs classes included in the APP template. These classes doesn't seem to be there in the windows 10 UWP apps. Is there a way by which we can handle the suspend/resume states?

推荐答案

有由社区正在开发一个有趣的框架(但主要是我觉得杰里·尼克松,安迪·威格利等)称为Template10。 Template10有引导程序 OnSuspending OnResuming 虚拟方法,您可以覆盖。我不知道那有做悬架/带Template10尚未恢复的确切的例子,但这个想法似乎是做的 App.xaml.cs从这个引导程序类继承,所以你可以很容易地覆盖我提到的方法。

There's an interesting framework being developed by the community (but mostly I think Jerry Nixon, Andy Wigley etc.) called Template10. Template10 has a Bootstrapper class with OnSuspending and OnResuming virtual methods that you can override. I am not sure that there's an exact example of doing suspension/resuming yet with Template10, but the idea seems to be to make App.xaml.cs inherit from this Bootstrapper class so you can easily override the methods I mentioned.

sealed partial class App : Common.BootStrapper
{
    public App()
    {
        InitializeComponent();
        this.SplashFactory = (e) => null;
    }

    public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
    {
        // start the user experience
        NavigationService.Navigate(typeof(Views.MainPage), "123");
        return Task.FromResult<object>(null);
    }

    public override Task OnSuspendingAsync(object s, SuspendingEventArgs e)
    {
        // handle suspending
    }

    public override void OnResuming(object s, object e)
    {
        // handle resuming
    }
}

这篇关于操作暂停,恢复和激活窗口10 UWP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆