Current location - Quotes Website - Signature design - How to get whether the current screen is in landscape mode or portrait mode
How to get whether the current screen is in landscape mode or portrait mode

The experiment found that the current screen width and height can be obtained through System.Windows.Forms.SystemInformation.VirtualScreen.Height and System.Windows.Forms.SystemInformation.VirtualScreen.Width in the mode described in the post. changes, and the height and width of the winform window can also be reset in this mode and it will take effect, but for the wpf window, changing the height and width of the window in this mode has no effect.

Why does changing the width and height of the WPF window have no effect in this mode?

The following is the code:

public MainWindow()

{

InitializeComponent();

// this.TopMost = true;

this.Topmost = true;

this.ShowInTaskbar = true;

this.ResizeMode = ResizeMode.CanResize;

this.Height = System.Windows.Forms.SystemInformation.VirtualScreen.Height;

this.Width = System.Windows.Forms.SystemInformation.VirtualScreen.Width;

}

private void ResetWndSize(object sender, EventArgs e)

{

//this.Height = System.Windows.Forms.SystemInformation.VirtualScreen.Height ;

//this.Width = System.Windows.Forms.SystemInformation.VirtualScreen.Width;

}

private void ResetWindowSizeBtn(object sender, RoutedEventArgs e )

{

this.Height = System.Windows.Forms.SystemInformation.VirtualScreen.Height;

this.Width = System.Windows.Forms.SystemInformation .VirtualScreen.Width;

}

In addition, if you want a wpf desktop application to be displayed on the windows8 start page, you can follow the following steps:

1 Create a wpf application

2 Set both the topmost and showintaskbar properties to true

3 Add the mainfest file to the application and set uiAccess='true'

4 Compile the program

5 Sign the digital signature

6 Copy the program to the program file directory of the system disk

7 Run the program

8 Switch to the windows8 start page, and you will find that your program will be displayed on it, as shown in the picture in the post.