I want to set the width & height of a Window
dynamically based on the user screens maximum width/height. How can I determine this programmatically?
The size of a 16:9 screen depends on how long the screen's diagonal is, as 16:9 is merely the ratio of the screen's width to its height. If you have the screens diagonal, you can multiply that measurement by 0.872 to get the screen's width. You can also multiply the diagonal by 0.49 to get the screen's height.
The screen width is equal to the aspect ratio width ARw times the screen diagonal divided by the square root of the aspect ratio width ARw squared plus the aspect ratio height ARh squared.
It is usually quoted as width × height, with the units in pixels: for example, 1024 × 768 means the width is 1024 pixels and the height is 768 pixels. This example would normally be spoken as "ten twenty-four by seven sixty-eight" or "ten twenty-four by seven six eight".
For the primary screen:
System.Windows.SystemParameters.PrimaryScreenWidth System.Windows.SystemParameters.PrimaryScreenHeight
(Note that there are also some other primary screen related properties which depend on various factors, Full*
& Maximised*
)
Virtual screen:
SystemParameters.VirtualScreenWidth SystemParameters.VirtualScreenHeight
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With