Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.Forms.Screen.AllScreens.

Is there an equivalent type or other mechanism to get the bounds of the entire desktop in WPF or do I need to use the WinForms type?

like image 427
dkackman Avatar asked Apr 24 '10 14:04

dkackman


People also ask

Is WPF same as Windows Forms?

Windows forms are mainly based on a pixel, whereas WPF is not pixel-based, which allows the scalability of the UI part for the application. Windows forms support data binding in a limited way, whereas WPF is fully supported data binding. Windows forms are not used with different themes or skins.

What is the replacement for WPF?

Universal Windows Platform. Both Windows Forms and WPF are old, and Microsoft is pointing developers towards its Universal Windows Platform (UWP) instead. UWP is an evolution of the new application platform introduced in Windows 8 in 2012.

Can we use WPF in Windows form application?

Add a WPF control to a Windows Form Your new WPF control is ready for use on the form. Windows Forms uses the ElementHost control to host WPF content. To add a WPF control to a Windows Form: Open Form1 in the Windows Forms Designer.

What is the replacement for WinForms?

WPF, would be your answer to Windows Forms if you are on the . NET platform.


1 Answers

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.

like image 86
Michael Brown Avatar answered Oct 06 '22 01:10

Michael Brown