简体   繁体   English

无法覆盖应用程序 class 中的 onBackgroundActivated 和 OnSuspending 事件:Winui3

[英]Unable to override onBackgroundActivated and OnSuspending events in Application class : Winui3

I am creating a winui3 application and having the latest .net SDK 5.0403 but I'm unable to override onBackgroundActivated , OnSuspending events in the App class that extends the Application class. I am creating a winui3 application and having the latest .net SDK 5.0403 but I'm unable to override onBackgroundActivated , OnSuspending events in the App class that extends the Application class. I have windows 10(version 19042), Windows.Foundation.UniversalApiContract (v4.0)我有 windows 10(版本 19042),Windows.Foundation.UniversalApiContract (v4.0)

在此处输入图像描述

The OnLaunched method is already overridden in the App.xaml.cs file that's included in the default WinUI 3 template in Visual Studio. OnLaunched方法已在App.xaml.cs文件中重写,该文件包含在 Visual Studio 的默认 WinUI 3 模板中。

And Suspending is an event that cannot be overriden but handled in the same class/file:并且Suspending是一个不能被覆盖但在同一个类/文件中处理的事件:

public partial class App : Application
{
    public App()
    {
        this.InitializeComponent();
        Suspending += OnSuspending;
    }


    protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
    {
        m_window = new MainWindow();
        m_window.Activate();
    }

    private void OnSuspending(object sender, SuspendingEventArgs e)
    {
        //...
    }

    private Window m_window;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM