Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Going fullscreen on secondary monitor

How can you program a dotNet Windows (or WPF) Application in order to let it going fullscreen on the secondary monitor?

like image 747
user91295 Avatar asked Apr 15 '09 20:04

user91295


People also ask

Why is my second monitor not full screen?

Typically, this is caused by a resolution or settings issue that can be resolved. Review your resolution settings: Go through our resolution section above, and make sure that your resolution settings match each monitor you are using. Use recommended or screen fitting options where possible.

How can I play fullscreen on second monitor while keeping controls on first monitor?

If you have two or more monitors and you want your videos to open on a second or third monitor, full screen, then do the following: Go to Tools and then Preferences or press Ctrl + P. Click on the Video icon towards the top. Check on the Fullscreen option in the Display section.


2 Answers

Extension method to Maximize a window to the secondary monitor (if there is one). Doesn't assume that the secondary monitor is System.Windows.Forms.Screen.AllScreens[2];

using System.Linq; using System.Windows;  namespace ExtendedControls {     static public class WindowExt     {          // NB : Best to call this function from the windows Loaded event or after showing the window         // (otherwise window is just positioned to fill the secondary monitor rather than being maximised).         public static void MaximizeToSecondaryMonitor(this Window window)         {             var secondaryScreen = System.Windows.Forms.Screen.AllScreens.Where(s => !s.Primary).FirstOrDefault();              if (secondaryScreen != null)             {                 if (!window.IsLoaded)                     window.WindowStartupLocation = WindowStartupLocation.Manual;                  var workingArea = secondaryScreen.WorkingArea;                 window.Left = workingArea.Left;                 window.Top = workingArea.Top;                 window.Width = workingArea.Width;                 window.Height = workingArea.Height;                 // If window isn't loaded then maxmizing will result in the window displaying on the primary monitor                 if ( window.IsLoaded )                     window.WindowState = WindowState.Maximized;             }         }     } } 
like image 108
grantnz Avatar answered Oct 20 '22 17:10

grantnz


For WPF apps look at this post. Ultimately it depends on when the WindowState is set to Maximized. If you set it in XAML or in window constructor (i.e. before the window is loaded) it will always be maximized onto primary display. If, on the other hand, you set WindowState to Maximized when the window is loaded - it will maximise on the screen on which it was maximized before.

like image 23
Alex_P Avatar answered Oct 20 '22 17:10

Alex_P