I have tried viewbox which stretch the views to the border of the window distorting the views. What are the methods out there to resize the views of the all controls, textfont dynamically when the application runs on different monitors?
3 Answers
SystemParameters Class allows you to retrieve primary screen size (and many other values). With a simple binding like
<Window ...
Height="{x:Static SystemParameters.PrimaryScreenHeight}"
Width="{x:Static SystemParameters.PrimaryScreenWidth}" />
you will be able to change the size of your view (Window
or UserControl
doesn't make difference). But, if you need an adaptive layout (e.g. your Grid
must fill the entire Window
) it's necessary to set Dock
properties, Alignment
values and so on.

- 1,493
- 8
- 20
-
1Actually should be an x:Static binding: `Height="{x:Static SystemParameters.PrimaryScreenHeight}"` – Alberto Nov 19 '13 at 07:54
-
You misunderstood my question. I don't need a window to fit the screen size but the whole UI re size dynamically/ proportionally with different screen resolution. – Kevin Q Nov 19 '13 at 08:17
-
Adapting Window to Screen the whole UI will resize appropriately (if your layout is properly designed). You don't need to think the javascipt fluid layout way, but use StackPanels, Dock and stretching options. You have styles, data triggers and other ways to achieve a dynamic/proportional UI redesign. – Francesco De Lisi Nov 19 '13 at 08:56
-
Stretching will force all controls to fill the parent layout which is not good UI as the size every controls are maximized. But setting fixed margin doesn't allow the UI resize proportionally when it's used in different resolution – Kevin Q Nov 20 '13 at 01:08
I would go on with HorizontalAlignment, VerticalAlignment and MinSize in this case. One of the main principle in WPF is a sizeless design. If you define them right it does not matter what is the current resolution. You also can define ratio, when you design grid columns and rows.
And as @Francesco De Lisi said, docking.

- 1,120
- 8
- 19
Beware of the zoom factor of your windows (100% / 125% / 150% / 200%). You can get the real screen size (visible pixel) by using the following property:
SystemParameters.FullPrimaryScreenHeight
SystemParameters.FullPrimaryScreenWidth

- 1,128
- 9
- 19