zoukankan      html  css  js  c++  java
  • WPF多屏最大化

      如果计算机存在多个显示器,这时设置wpf窗口为最大化,窗口只能在主显示器中实现最大化,如果想要实现窗口拉伸至多屏,需要获取所有显示器分辨率之和。这时用到了System.Windows.SystemParameters命名空间。
      SystemParameters 是一个类,包含多个系统参数值属性。其中VirtualScreenWidth与VirtualScreenHeight可分别获取虚拟屏上的宽高。虚拟屏即是所有监视器边框。
      C#代码:

            public MainWindow()
            {
                InitializeComponent();
                FullScreen();
            }
    
            private void FullScreen()
            {
                this.WindowState = WindowState.Normal;
                this.WindowStyle = System.Windows.WindowStyle.None;
                this.ResizeMode = System.Windows.ResizeMode.NoResize;
                this.Left = 0;
                this.Top = 0;
                this.Width = System.Windows.SystemParameters.VirtualScreenWidth;
                this.Height = System.Windows.SystemParameters.VirtualScreenHeight;
            }

       在 XAML 中,可以使用 SystemParameters 的成员作为静态属性用法或动态资源引用达到同样的效果:  

    <Window x:Class="WpfApplication2.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow"
            WindowState="Normal" WindowStyle="None" ResizeMode="NoResize" Left="0" Top="0"
            Height="{x:Static SystemParameters.VirtualScreenHeight}" Width="{x:Static SystemParameters.VirtualScreenWidth}">
        <Grid>
        </Grid>
    </Window>

      

  • 相关阅读:
    ssh 远程命令
    POJ 2287
    POJ 2376
    hihoCoder1488
    POJ1854
    HDU 5510
    HDU 4352
    CodeForces 55D
    HDU 1517
    CodeForces 1200F
  • 原文地址:https://www.cnblogs.com/infly123/p/3818534.html
Copyright © 2011-2022 走看看