Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dual monitor dual window app in wpf

I'm trying to create a wpf video player with media element. My goal is making muliple windows for that application. each of the windows will show up on different monitors. Like the MainWindow will get the resolution of primary monitor and resize itself to go full screen. The Second window on secondary monitor and so...

So far, I've made the MainWindow fullscreen on the primary monitor. but I've no idea how to show the second window on second monitor with it's resolution. please help.

like image 490
D.K. Avatar asked Feb 04 '26 05:02

D.K.


1 Answers

Easiest option is to display it. And after the show() method, resize it.

            // display on second window
        NewWindow win = new NewWindow();
        System.Windows.Forms.Screen s1 = System.Windows.Forms.Screen.AllScreens[2];

        System.Drawing.Rectangle r1 = s1.WorkingArea;
        win.WindowState = System.Windows.WindowState.Normal;
        win.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
        win.Top = r1.Top;
        win.Left = r1.Left;

        win.Show();
        win.WindowState = System.Windows.WindowState.Maximized;
like image 104
tkelch Avatar answered Feb 05 '26 18:02

tkelch