在类型“应用程序”中找不到属性“退出”

时间:2020-08-04 15:52:30

标签: visual-studio uwp

enter image description here

我的 App.xaml 代码无法识别Exit属性,我也不知道为什么。 App.xaml.cs 代码也无法识别ExitEVentArgs

1 个答案:

答案 0 :(得分:0)

在“应用程序”类型中找不到属性“退出”

Hans Passant是正确的,UWP平台Application不包含Exit 事件,但是它具有Exit方法,您可以调用它来退出当前应用手动。

如果您要检测应用程序是否存在,可以侦听Suspending事件,该事件在应用程序从其他状态转换为“挂起”状态时发生。

public App()
{
    this.InitializeComponent();
    this.Construct();
    this.Suspending += App_Suspending;
}

private void App_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
{
    
}

有关更多详细信息,请参阅UWP life cycle

相关问题