Resize WPF application to different screen resolutions.

Juan Giraldo
Juan Giraldo used Ask the Experts™
on
I built a wpf application for a screen resolution of 1920*1080 ...
however the user will sometimes use a resolution 3810*2160.
How to i make my application so it keeps its aspect ratio in a way that if in a screen resolution of 1920*1080  occupies 80% of screen then in a screen resolution of 3840*2160 it also occupies 80% of screen.
I will be looking into font sizes and all that stuff too... but at least for now I need that the grids, windows and controls all resize accordingly.

Regards.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Your can try to use system parameters to get  screen resolution:
<Window x:Class="YourApplication.MainWindow"
//------your other code--------
   Height="{Binding SystemParameters.PrimaryScreenHeight}" 
    Width="{Binding SystemParameters.PrimaryScreenWidth}">

Open in new window

Generally WPF containers are designed to do just that.  Grids / stackpanels etc should all flow as the screen increases.
Did you use a Canvas as the base control?

And specify what you mean in terms of the scaling.  If this happens to be a graphic-centric app, then the easiest way would be to apply a scaletransform (render) to the root panel based on the screen dimensions.
But that would increase everything (including font sizes).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial