Link to home
Start Free TrialLog in
Avatar of Juan Giraldo
Juan Giraldo

asked on

Resize WPF application to different screen resolutions.

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.
Avatar of Misha
Misha
Flag of Russian Federation image

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).
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.