日期:2014-05-17  浏览次数:21105 次

WPF 取消全屏
WPF加了如下代码之后
调用this.WindowState = System.Windows.WindowState.Maximized;
会全屏

WindowStyle="None"

如何取消掉这个操作!!
就是加了WindowStyle="None"之后 调用WindowState = WindowState.Maximized;不全屏的方法

------解决方案--------------------

        public Form10()
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.None;
            this.Shown += new EventHandler(Form10_Shown);
        }

        void Form10_Shown(object sender, EventArgs e)
        {
            Application.DoEvents();
            this.Location = new Point(0, 0);
            this.Width = Screen.PrimaryScreen.WorkingArea.Width;
            this.Height = Screen.PrimaryScreen.WorkingArea.Height;
            this.PreviewKeyDown += new PreviewKeyDownEventHandler(Form10_PreviewKeyDown);
        }

        void Form10_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyValue == 27)//Esc键
            {
                this.Close();
            }
        }
要放到Shown这个事件里效果才好。