Is there a WPF equaivalent to System.Windows.Forms.Screen?

后端 未结 4 1237
傲寒
傲寒 2021-02-01 20:11

I\'m trying to create a WPF window that will encompass the entire Desktop working area. In WinForms I\'d do this by getting the Union of all the bounds in System.Windows.F

相关标签:
4条回答
  • 2021-02-01 20:51

    I have successfully used WpfScreenHelper 0.3.0.0, currently on Github or Nuget, https://github.com/micdenny/WpfScreenHelper

    It does what the .NET framework should have done so many years ago. I needed to check if some coordinates exist on any screen in WPF, as in these:

    • Very germane: Determine if an open WPF window is visible on any monitor
    • Forms-only and inadequate WPF suggestions: Determining if a form is completely off screen
    0 讨论(0)
  • 2021-02-01 20:57

    Try SystemParameters.VirtualScreen* (Top, Left, Height, and Width) properties. http://msdn.microsoft.com/en-us/library/system.windows.systemparameters.virtualscreenheight(v=VS.100).aspx

    Don't use winforms api because it doesn't take into account the fact that WPF's measurement units are not pixels. I came across this issue just recently because I'm losing my vision and have my monitor set to a higher dpi. The codebase I was working on used the Winforms Settings and the UI was larger than my screen.

    If you're going to use the winforms api. Look at this blog post on calculating the DPI factor.

    0 讨论(0)
  • 2021-02-01 21:00

    Just use WinForms. I do not think there is a direct WPF equivalent.

    0 讨论(0)
  • 2021-02-01 21:13

    You could try SystemParameters.VirtualScreenWidth and associated parameters. That might not provide as good as a result as continuing with the WinForms API.

    The only downside I can see with the WinForms type is an extra dependency and the larger working set related to that.

    0 讨论(0)
提交回复
热议问题