WPF Maximized Window bigger than screen

后端 未结 5 1507
情话喂你
情话喂你 2021-02-19 06:24

When creating a WPF window with AllowsTransparency=\"True\" WindowStyle=\"None\" and maximizing it via this.WindowState = WindowState.Maximized; the Wi

5条回答
  •  盖世英雄少女心
    2021-02-19 07:13

    If you only care about the correct dimensions of your window and have no trouble with the appearance, you can wrap the contents of the window in System.Windows.Controls.Canvas like this:

    
    ...
    
    

    Then you can use MyCanvas.ActualWidth and MyCanvas.ActualHeight to get the resolution of the current screen, with DPI settings taken into account and in device independent units. It doesn't add any margins like the maximized window itself does. It should work with multiple monitors too.

    (Canvas accepts UIElements as children, so you should be able to use it with any content.)

提交回复
热议问题