wpf dual monitor

public partial class App : System.Windows.Application
    {

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

            SetupWindows();
        }
         
        private void SetupWindows()
        {
            System.Windows.Forms.Screen mainScreen = Screen.AllScreens[0]; ;
            WinLeft leftWin = new WinLeft()
            {
                WindowStartupLocation = WindowStartupLocation.Manual,
                WindowState = System.Windows.WindowState.Normal,
                Left = mainScreen.WorkingArea.Left,
                Top = mainScreen.WorkingArea.Top,
                Width = mainScreen.WorkingArea.Width,
                Height = mainScreen.WorkingArea.Height
            };           

            System.Windows.Forms.Screen secondaryScreen = Screen.AllScreens[1];
            WinRight rightWin = new WinRight()
            {
                WindowStartupLocation = WindowStartupLocation.Manual,
                WindowState = System.Windows.WindowState.Normal,
                Left = secondaryScreen.WorkingArea.Left,
                Top = secondaryScreen.WorkingArea.Top,
                Width = secondaryScreen.WorkingArea.Width,
                Height = secondaryScreen.WorkingArea.Height
            };

           
            leftWin.Show();
            leftWin.WindowState = WindowState.Maximized;
            rightWin.Show();
            rightWin.WindowState = WindowState.Maximized;
            rightWin.Owner = leftWin;
        }
    }

wpf dual monitor_第1张图片

 

你可能感兴趣的:(wpf dual monitor)