首页 新闻 会员 周边

WPF 窗口分屏

0
悬赏园豆:5 [已关闭问题] 关闭于 2015-06-02 16:19

刚接触wpf,给系统做个触摸屏的程序,需要在我的wpf程序启动的时候做出分屏动作,2个窗口,一个窗口显示到一个屏幕里。

这个应该如何实现?

Vincent8464的主页 Vincent8464 | 初学一级 | 园豆:17
提问于:2015-06-02 14:21
< >
分享
所有回答(1)
0
需要引用:

using System.Windows.Forms;
using System.Drawing;


1
public partial class App : System.Windows.Application 2 { 3 protected override void OnStartup(StartupEventArgs e) 4 { 5 6 base.OnStartup(e); 7 MainWindow w1 = new MainWindow();//主窗口 8 RevealWindow w2 = new RevealWindow();//副窗口 9 if (Screen.AllScreens.Length > 1) 10 { 11 12 Screen s1 = Screen.AllScreens[0];//主屏幕 13 Screen s2 = Screen.AllScreens[1];//副屏幕 14 Rectangle r1 = s1.WorkingArea; 15 Rectangle r2 = s2.WorkingArea; 16           //因为我的主副屏幕是反的所以主窗口放入副屏幕中。
17 //主窗口放入副屏幕中 18 w1.Top = r2.Top; 19 w1.Left = r2.Left; 20 //副窗口放入主屏幕中 21 w2.Top = r1.Top; 22 w2.Left = r1.Left; 23 24 w1.Show(); 25 w2.Show(); 26 27 w2.Owner = w1; 28 } 29 } 30 }
Vincent8464 | 园豆:17 (初学一级) | 2015-06-02 16:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册