WPF Resolution Handling - c#

I've got a list of 3 resolutions I need to target with a WPF application. However, I've never used WPF before and was wondering what the best way of targetting these would be.
1024x600, 1600,768 and 1024x576 are the main resolutions.
The application does not run full screen, so should I simply target the lowest one (1024 x 576) or is there a better way of handling this in WPF?
Thanks

One of the advantages of WPF/Silverlight layout controls is that you don't need to know the target resolution.
It's possible to design your interface to be fully dynamic. You should be able to design it in a way that it looks good on any resolution.
I just wouldn't set any constraints such as MinWidth or MinHeight that would cause it to not fit in the smallest resolution you want to target.

It depends.
If your program is a simple collection of non-resizable controls, you should design your form for the smallest resolution and be non-resizable.
If your program has resizable controls (eg, a grid or multi-line textbox), you should make a resizable form that can fit the smallest resolution, but can be resized to take advantage of larger screens.

Related

Win2D’s CanvasControl’s text is jittery with certain screen resolutions

More precisely, when I use certain display scales in Windows (those that don’t produce perfect 1:1 pixel layout. 150%, 175%, etc), the text doesn’t always redraw itself in the exact same position during every redraw. It is as if it dances a bit. However, if I scale the display perfectly (100% or 200%, for example) the effect is nonexistent.
Is there a fix for this? I spent so much time developing a custom text editor with Win2D’s CanvasControl being used draw the UI text, then discover this. I absolutely cannot continue development under these circumstances, as I am not aware of a better alternative to Win2D’s CanvasControl for presenting text for a custom text editor.
Any advice helps! Thanks!
UWP is optimized for high resolution. The unit used is effective pixels (epx). In different resolutions, the application will scale accordingly.
In order to apply consistent performance at various resolutions, there is a very important concept:
The sizes, margins, and positions of UI elements should always be in multiples of 4 epx in your UWP apps.
So you can check your app and resize text and controls to fit this principle.
See more in this document: Introduction to UWP app design

C# - WPF responsive design for different resolutions

I´m designing an desktop app in WPF. My problem is the resolution, the minimum resolution that can support the app is 1024x768(for crt monitors) and in this resolution maximizing the app seems okay and good, but when i try the app in higher resolution then the gap between my components and their size according to resolution seems very very awful and unprofessional specially in very high resolution the empty space which make it more worst and ugly. please suggest me some easy fast guide or documentation please.... thank you
When designing your WPF application, it's advisable to use one of the predefined layouts such as stacklayout, grid, dock panel etc. as these tend to be more responsive than defining the your own static layout.
Check the link below on how you can use these layouts.
https://wpftutorial.net/layoutproperties.html

WPF UI size, pixel vs .png pixel

I was given UI design for project. This design is made by Photoshop. In this design every UI element's (button, textbox, listbox, etc) height and width are given in pixels. I am following that design while making user interface in WPF.
But, even I do exactly what is given UI design, image and my UI are not same. It seems WPF pixel is not same as Photoshop pixel(I know it is nonsense). Window, Button, TextBox, etc, sizes are more bigger than they are in .png picture.
Is there something am I missing?
Thank You
WPF does not operate in pixels, it operates in device-independent units, which might or might not equal to 1 physical pixel, depending on your monitor and OS settings.
Without seeing your actual UI its hard to tell what do you mean by "image and my UI are not same". There are a couple things you could try though. First, if you experience blur when rendering shapes or images - try setting either UseLayoutRounding or SnapToDevicePixels to True. Second, if you feel that the distance between different elements is larger than it should be - make sure that you account for non-zero Margin-s and Padding-s (some controls have those by default), when building your layout.
If nothing helps, try using Snoop. It will allow you to inspect your UI while your application is running, and among other things it will tell you the exact size of any element and, more importantly, why it has that size.

How to make .net winform application resolution friendly

I am trying to make my winforms application made with C#.Net, resolution friendly. I tried to do so in programming way by just adjusting a size of all control according to ratio of screen resolution. But it doesn't give perfect resolution in every forms.
I tried to do so in programming way by just adjusting a size of all control according to ratio of screen resolution.
I think you mix two things.
To adjust your form to the Windows DPI settings (making your controls smaller or larger), you don't need to do anything, this is performed automatically. Just change the DPI settings and check the effect.
To adapt your forms to the actual resolution just make it sure that your forms are either resizable (and the controls are docked) or the non-resizable dialogs will show at least some scrollbars if the resolution is too small. Anchors can be a pain especially if you have derived forms or user controls but you can always use docking.
You could also use certain resolution breakpoints where the size of the anchors change. For example at 1024x768 1600x900 1920x1080 the controls all change to a set size, inbetween they just take the closest resolution breakpoint to them (1200x900 would take 1024x768).
Often I've had problems trying to make them completely dynamic and I've been handling it like this. Upon resize just call a function that checks the current size and if needed resizes all the anchors.

Bigger is better, but how do I make sure my PictureBoxes are resized relative to resolution?

We have a bunch of forms with alot of PictureBoxes on them. They're basically a representation of an engineering system with pipes connected to pumps and whatever. Each element is it's own picturebox, so there's a few hundred.
The problem we have is that when we take the app to a large 40"+ TV, there's too much space everywhere and it doesn't look the way it does on the developer's screen. So we designed it for these large TV's but when we look at it on a normal computer screen it's all wrong.
So how do we design the form with pictureboxes for the actual images to resize and reposition the controls relative to the size of the resolution it's being viewed on? If we simply anchor everything then the image sizes themselves are not relative to the display it's seen on.
Much appreciated!
In a Winforms solution you will have to do at least some of the resize calculations if anchoring and docking do not provide you with the required results.
If it is really important to you to be able to design the UI in Visual Studio I recommend writing custom controls that expose the desired resize properties and resize behavior and perhaps even a custom designer to support the design time features.
It might not be feasible but you could consider having a look at WPF, it has a ViewBox control that might simply be the answer to your needs.

Categories

Resources