display window on secondary monitor

amir stack

I want to display a Window on secondary monitor, as follows:

Queue<string> itemQueue = new Queue<string>();

MonitorWindow monitor = new MonitorWindow(itemQueue);

var secondaryScreen = System.Windows.Forms.Screen.AllScreens.Where(s => !s.Primary)
                                                            .FirstOrDefault();

if (secondaryScreen != null)
{
     monitor.WindowStartupLocation = WindowStartupLocation.Manual;
     var workingArea = secondaryScreen.WorkingArea;
     monitor.Left = workingArea.Left;
     monitor.Top = workingArea.Top;
     monitor.Width = workingArea.Width;
     monitor.Height = workingArea.Height;
     monitor.Show();

}

The properties have correct values, but this maximizes the Window on the primary monitor. can you help me?

amir stack

Ok, I've fixed the problem with remove the property WindowState="Maximized" in XAML code of MonitorWindow and changed the program as follows:

        Queue<string> itemQueue = new Queue<string>();

        MonitorWindow monitor = new MonitorWindow(itemQueue);

        var secondaryScreen = System.Windows.Forms.Screen.AllScreens.Where(s => !s.Primary).FirstOrDefault();

        if (secondaryScreen != null)
        {
            if (!monitor.IsLoaded)
                monitor.WindowStartupLocation = WindowStartupLocation.Manual;
            var workingArea = secondaryScreen.WorkingArea;
            monitor.Left = workingArea.Left;
            monitor.Top = workingArea.Top;
            monitor.Width = workingArea.Width;
            monitor.Height = workingArea.Height;
            // If window isn't loaded then maxmizing will result in the window displaying on the primary monitor
            monitor.Show();
            if (monitor.IsLoaded)
                monitor.WindowState = WindowState.Maximized;
        }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

display window on secondary monitor

From Dev

How to make a window fullscreen in a secondary display with tkinter?

From Dev

How can I instantly move the active window to a secondary monitor in openbox?

From Dev

How can I display the Windows 8 Start Screen on a secondary monitor?

From Dev

Why won't my taskbar display on my secondary monitor?

From Dev

Tkinter window not filling screen in zoomed state on secondary display

From Dev

Bad secondary monitor resolution

From Dev

How to display window form fullscreen on second monitor in Qt?

From Dev

Get the display resolution a window is on in a multi monitor set up

From Dev

How do I get secondary monitor to display separate video feed in Windows 7?

From Dev

Secondary Monitor shows part of Primary Monitor

From Dev

How to disable a secondary monitor (with ChangeDisplaySettingsEx)?

From Dev

Windows 8 Mail on secondary monitor

From Dev

VS 2012: Debugging on Secondary Monitor

From Dev

dual monitor, rotate secondary screen

From Dev

Secondary monitor not connecting in 18.04 LTS

From Dev

"Show Desktop" button on secondary monitor

From Dev

Secondary Monitor Applications Graphically Freezing

From Dev

How to focus on a secondary window?

From Dev

How does windows decide which monitor to display a window on and how can I control it?

From Dev

Window in fullscreen on second monitor

From Dev

Window in fullscreen on second monitor

From Dev

How to automatically disable secondary monitor in Windows 7

From Dev

How to disable zoom for my secondary monitor

From Dev

disable Ubuntu from thinking that there is a secondary monitor

From Dev

Huge elements on secondary monitor with lower resolution

From Dev

Secondary monitor waking up before primary

From Dev

how to configure terminal to always launch on secondary monitor?

From Dev

Error Opening Secondary Window in WPF

Related Related

  1. 1

    display window on secondary monitor

  2. 2

    How to make a window fullscreen in a secondary display with tkinter?

  3. 3

    How can I instantly move the active window to a secondary monitor in openbox?

  4. 4

    How can I display the Windows 8 Start Screen on a secondary monitor?

  5. 5

    Why won't my taskbar display on my secondary monitor?

  6. 6

    Tkinter window not filling screen in zoomed state on secondary display

  7. 7

    Bad secondary monitor resolution

  8. 8

    How to display window form fullscreen on second monitor in Qt?

  9. 9

    Get the display resolution a window is on in a multi monitor set up

  10. 10

    How do I get secondary monitor to display separate video feed in Windows 7?

  11. 11

    Secondary Monitor shows part of Primary Monitor

  12. 12

    How to disable a secondary monitor (with ChangeDisplaySettingsEx)?

  13. 13

    Windows 8 Mail on secondary monitor

  14. 14

    VS 2012: Debugging on Secondary Monitor

  15. 15

    dual monitor, rotate secondary screen

  16. 16

    Secondary monitor not connecting in 18.04 LTS

  17. 17

    "Show Desktop" button on secondary monitor

  18. 18

    Secondary Monitor Applications Graphically Freezing

  19. 19

    How to focus on a secondary window?

  20. 20

    How does windows decide which monitor to display a window on and how can I control it?

  21. 21

    Window in fullscreen on second monitor

  22. 22

    Window in fullscreen on second monitor

  23. 23

    How to automatically disable secondary monitor in Windows 7

  24. 24

    How to disable zoom for my secondary monitor

  25. 25

    disable Ubuntu from thinking that there is a secondary monitor

  26. 26

    Huge elements on secondary monitor with lower resolution

  27. 27

    Secondary monitor waking up before primary

  28. 28

    how to configure terminal to always launch on secondary monitor?

  29. 29

    Error Opening Secondary Window in WPF

HotTag

Archive