如何在 uwp win 10 的第二个或第三个显示器上显示新的 window

how to show a new window on the second or third monitor of uwp win 10

我希望我的程序能够 select 将在其上打开新 window 的监视器

现在我的代码如下所示:

AppWindow appWindow = await AppWindow.TryCreateAsync();
Frame OpenPage1 = new Frame();
OpenPage1.Navigate(typeof(Projector));
ElementCompositionPreview.SetAppWindowContent(appWindow, OpenPage1);
appWindow.Presenter.RequestPresentation(AppWindowPresentationKind.FullScreen);

await appWindow.TryShowAsync();

它在当前监视器上打开一个window。我希望 window 在 selected 监视器

上打开

其他问题:如何防止此 window 崩溃?

how to show a new window on the second or third monitor of uwp win 10

正如 Raymond Chen 所说,您可以使用 RequestMoveToDisplayRegion 方法在辅助 DisplayRegion 中显示 AppWindow。

代码示例可以参考AppWindow官方代码示例Scenario2_DisplayRegion.

 DisplayRegion secondaryDisplayRegion = GetOtherDisplayRegion(ApplicationView.GetForCurrentView().GetDisplayRegions()[0]); 
 if (secondaryDisplayRegion != null)
  {
     appWindow.RequestMoveToDisplayRegion(secondaryDisplayRegion);
  }