如何防止Windows 10 XAML应用程序的多个实例?
问题描述:
我正在使用Windows 10应用程序。 Windows 10应用程序的新功能之一是同一应用程序的多个实例(窗口)的功能。我想禁用这个。有没有人找到关于这种情况的文档?如何防止Windows 10 XAML应用程序的多个实例?
答
您可以覆盖OnLaunch在App.xaml.cs方法:
protected async override void OnLaunched(LaunchActivatedEventArgs e)
{
if (e.PreviousExecutionState != ApplicationExecutionState.Running) //Check if is there any instance of the App is already running
{
base.OnLaunched(e);
}
}
你检查你的项目属性?大多数时候,我发现设置周围的属性。 – MiltoxBeyond
是的,我没有看到这种情况。 – Dylan