首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

WPF 撤销全屏

2013-11-15 
WPF 取消全屏WPF加了如下代码之后调用this.WindowState System.Windows.WindowState.Maximized会全屏Wi

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这个事件里效果才好。

热点排行