[WPF]同时在2个监视器上创建一个窗口 [英] [WPF] Create one window at 2 monitors at same time

查看:64
本文介绍了[WPF]同时在2个监视器上创建一个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,我正在开发WPF应用程序,在这里我有窗口,应该同时在两个监视器上显示它(它的宽度应该等于该监视器的宽度之和,以及要占用高度的高度来自每个监视器-因此每个监视器可能有所不同). 我也有可移动的控件,我应该通过此监视器.但是找不到路,怎么做.

i`m developing WPF application, where i have window, that should be shown at two monitors at same time(it should have width, that equals sum of width this monitors, and height, that take height from each monitor - so it could be different for each monitor). Also i have movable control, that i should move through this monitors. But can`t find the way, how to do it.

有人有同样的问题,怎么办?

Is anyone had same problem and how to do it?

谢谢您的回复!

推荐答案

抱歉,我的回复很晚.

尝试使用WinForm API, 添加  System.Windows.Forms和System.Drawing dll.

Try to use WinForm api,  add  System.Windows.Forms and System.Drawing dll.

在App类中如下重写OnStartup方法.

Override the OnStartup method as below in App class. 

protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            Window1 w1 = new Window1();
            Window2 w2 = new Window2();


            Screen s1 = Screen.AllScreens[0];
            Screen s2 = Screen.AllScreens[1];

            Rectangle r1 = s1.WorkingArea;
            Rectangle r2 = s2.WorkingArea;

            w1.Top = r1.Top;
            w1.Left = r1.Left;

            w2.Top = r2.Top;
            w2.Left = r2.Left;

            w1.Show();
            w2.Show();

            w2.Owner = w1;
        }

如何在辅助显示中设置WPF窗口位置

最好的问候,

鲍勃


这篇关于[WPF]同时在2个监视器上创建一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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