在 UWP 中的辅助监视器上打开新窗口 [英] Open new window on secondary monitor in UWP
本文介绍了在 UWP 中的辅助监视器上打开新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有两个显示器的 UWP 项目,我想用它在辅助显示器上打开一个新窗口.应用包括三个部分:
I have a UWP project with two monitors that I want to use to open a new window on a secondary monitor. The application includes three parts:
- 在第一台显示器上打开主页
- 创建新页面
- 在辅助监视器上打开
第一和第二部分我写对了,但我找不到第三部分的解决方案.
I wrote the first and second parts correctly, but I can't find a solution for the third part.
请帮我将窗口移到另一台显示器上.
Please help me with moving the window to another monitor.
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
//called creat new page function
NewWindow();
}
private async void NewWindow()
{
var myview = CoreApplication.CreateNewView();
int newid = 0;
await myview.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Frame newframe = new Frame();
newframe.Navigate(typeof(Newpage), null);
Window.Current.Content = newframe;
Window.Current.Activate();
ApplicationView.GetForCurrentView().Title = "Z";
newid = ApplicationView.GetForCurrentView().Id;
});
await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newid, ViewSizePreference.UseMinimum);
}
}
推荐答案
我找到了解决方案并使用了 ProjectionManger 类.
I found the solution and used ProjectionManger Class.
private async void expand()
{
var NewWindow = CoreApplication.CreateNewView();
int Windowid = ApplicationView.GetForCurrentView().Id;
int NewWindowid = 0;
await NewWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Frame newframe = new Frame();
newframe.Navigate(typeof(Newpage), null);
Window.Current.Content = newframe;
Window.Current.Activate();
ApplicationView.GetForCurrentView().Title = "New Page";
NewWindowid = ApplicationView.GetForCurrentView().Id;
});
//Call ProjectionManager class for moving new window to secodary display
bool available = ProjectionManager.ProjectionDisplayAvailable;
ProjectionManager.ProjectionDisplayAvailableChanged += (s, e) =>
{
available = ProjectionManager.ProjectionDisplayAvailable;
};
await ProjectionManager.StartProjectingAsync(NewWindowid, Windowid);
}
这篇关于在 UWP 中的辅助监视器上打开新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文