WEB开发网
开发学院软件开发C语言 C#开发WPF/Silverlight动画及游戏系列教程(Game C... 阅读

C#开发WPF/Silverlight动画及游戏系列教程(Game Course):(二十三)自适应性窗口化与全屏化(WPF Only)

 2010-09-30 20:48:58 来源:WEB开发网   
核心提示: private void ChangeWindowMode(object sender, RoutedEventArgs e) { Button button = e.Source as Button; string mode = button.Content.ToString(); if (

        private void ChangeWindowMode(object sender, RoutedEventArgs e) {

            Button button = e.Source as Button;

            string mode = button.Content.ToString();

            if (mode == "全屏") {

                this.WindowStyle = WindowStyle.None;

                this.WindowState = WindowState.Maximized;

                button.Content = "窗口";

            } else if (mode == "窗口") {

                this.WindowStyle = WindowStyle.SingleBorderWindow;

                this.WindowState = WindowState.Normal;

                button.Content = "全屏";

            }

        }

需要切换全屏时,我们只需要将窗口的标题栏与边框去掉(WindowStyle.None),并且设置窗口模式为最大化(WindowState.Maximized)即可;而如果需要将游戏窗口化则只需将窗口模式设置为单边框窗口(WindowStyle.SingleBorderWindow)并还原窗口(WindowState.Normal)即可。通过此方法实现的窗口化与全屏化的效果图如下:

C#开发WPF/Silverlight动画及游戏系列教程(Game Course):(二十三)自适应性窗口化与全屏化(WPF Only)

Tags:开发 WPF Silverlight

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接