在辅助监视器上打开新窗口 [英] open new windows on secondary monitor

查看:92
本文介绍了在辅助监视器上打开新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有两台显示器,我想在辅助显示器上打开一个新窗口。申请包括两部分:

I have two monitors that I want to open a new window on secondary monitor. Application include two parts:


  1. 创建新页面
  2. 移至辅助监视器


<我正确地写了第一部分。 但我找不到次要部分的解决方案。

请帮我将窗口移动到另一台显示器。

please help me for moving window to another monitor.

谢谢, 

public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent();

//调用creat新页面函数
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;
});

等待ApplicationViewSwitcher.TryShowAsStandaloneAsync(newid,ViewSizePreference.UseMinimum);

}

}

//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); } }

推荐答案

您好,

将Form的StartPosition设置为Manual,然后使用以下代码。当我的计算机上有三台显示器时,代码将窗体/窗口放在第二台显示器上。

Set the Form's StartPosition to Manual then use the following code. When running on my computer which has three monitors the code positions the form/window in the second monitor.

Location = Screen.AllScreens[1].WorkingArea.Location;

如果不确定有多少台显示器使用

If unsure how many monitors there are use

Screen.AllScreens.Length


这篇关于在辅助监视器上打开新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆