Independent WPF-independent applications regardless of monitor size

How can I develop independent and independent in size wpf applications. Regardless of the size of the monitor, suppose I develop wpf applications on a 15-inch monitor, and when I look at these applications on a 17-inch monitor, then often the user interface looks different, since I can get rid of this problem in WPF. please tell us in detail. thanks

+4
source share
3 answers

What you are looking for is Liquid Layout in WPF.

Avoid specifying explicit widths and heights for your elements, and it should scale to any available screen resolution.

Of course, MinWidth, MaxWidth and MinHeight, MaxHeight are also useful for size limits.

Reference:

+10
source

This is a pretty tricky question. Basically, WPF was created to create a permission-independent application. For example, all values ​​(width, height, etc.) are located in Device Independent Pixels , where each dot has a size of 1/96 inch (which corresponds to one pixel per dot for a monitor with a DPI value set to 96).

But, of course, this will not allow creating applications completely independent of the device. Here you need to remember that you need to use the appropriate layout mechanisms, for example, using DockPanel , StackPanel or Grid , and not Canvas . Your controls should be set to fill the entire available space ( HorizontalAlignment set to Stretch ), only some should have explicitly set Width or Height .

This is a pretty big topic, good practices that will allow you to complete your task are distributed across the network and books, probably no one can post it here in the short version.

+4
source

If the DPI for displaying the system is set correctly, WPF must scale the interface accordingly.

+1
source

Source: https://habr.com/ru/post/1338421/


All Articles