WPF full screen on maximize

后端 未结 9 1874
醉话见心
醉话见心 2021-02-04 12:56

I basically want to have my WPF window to go in full screen mode, when F11 is pressed or the maximize button in the right top corner of the window is pressed.

While the

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 13:32

    If there is still someone that need a smooth full screen of course tested only on windows 10! In windows 10 minimized do less flickering if you maintain this code order!

        public bool IsFullscreen = false;
        public WindowState lastWindowState;
        private void player_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (IsFullscreen)
            {
                this.WindowStyle = WindowStyle.SingleBorderWindow;
                this.WindowState = lastWindowState;
                IsFullscreen = false;
    
            }
            else
            {
                lastWindowState = this.WindowState;
    
                this.WindowStyle = WindowStyle.None;
                if (this.WindowState == WindowState.Maximized)
                    this.WindowState = WindowState.Minimized;
                this.WindowState = WindowState.Maximized;
                IsFullscreen = true;
            }
        }
    

提交回复
热议问题