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

Time:02-12

I want my program to be able to select the monitor on which a new window will be opened

now my code looks like this:

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();

It opens a window on the current monitor. I want the window to open on the selected monitor

Additional question: How can I prevent this window from collapsing?

CodePudding user response:

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

As Raymond Chen said you could use RequestMoveToDisplayRegion method to display AppWindow in secondary DisplayRegion.

For code sample you could refer to AppWindow official code sample Scenario2_DisplayRegion.

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