Going fullscreen on secondary monitor

前端 未结 7 1629
离开以前
离开以前 2020-11-30 02:31

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

相关标签:
7条回答
  • 2020-11-30 03:09

    It's not clear from your question if you are looking for a way to move the window to the secondary monitor and then go fullscreen, or if you are just looking to support fullscreen mode on whatever monitor the window is on (which may be primary or secondary).

    If the later, for a WPF window, though not quite the same as fullscreen mode, you can remove the borders when it is maximized and restore the border when not maximized. No need to check for which monitor, etc. The display of the caption/title bar is controlled by the border state.

        protected override void OnStateChanged(EventArgs e)
        {
            if (WindowState == WindowState.Maximized)
            {
                if (WindowStyle.None != WindowStyle)
                    WindowStyle = WindowStyle.None;
            }
            else if (WindowStyle != WindowStyle.SingleBorderWindow)
                WindowStyle = WindowStyle.SingleBorderWindow;
    
            base.OnStateChanged(e);
        }
    

    Credit goes to Pavel for his Forms-based answer in the current question and to Nir for his answer in this question.

    0 讨论(0)
提交回复
热议问题