Tips for improving your desktop applications for higher-DPI displays (WinForms/WPF)
Posted: (EET/GMT+2)
Modern monitors are big and sharp, and if you are developing applications for them, you need to pay attention. On Windows, a high-DPI displays works best with applications that are marked to be high-DPI compatible. Older desktop applications without this setting can look blurry instead on such displayes. A few small changes go a long way for WinForms and WPF.
To make your .NET application look better, follow these steps:
1) Declare DPI awareness in the app manifest:
<!-- app.manifest -->
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings>
<!-- for Windows 10 -->
<dpiAwareness>PerMonitorV2</dpiAwareness>
<!-- for older Windows 7/8 -->
<dpiAware>true/pm</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
2) For WinForms: enable DPI-based autoscaling and avoid hardcoded sizes:
// in your form constructor this.AutoScaleMode = AutoScaleMode.Dpi; // prefer layout panels and Anchor/Dock over fixed pixel coordinates
3) For WPF: it is DPI-aware by default, but you improve clarity with layout rounding:
<Window UseLayoutRounding="True" SnapsToDevicePixels="True"> <TextOptions.TextFormattingMode>Display</TextOptions.TextFormattingMode> </Window>
4) Use vector imahes (WPF) or multiple image scales (WinForms) and test on mixed-DPI multi-monitor setups. Avoid drawing text to bitmaps; let the framework render text.
Small tweaks like these keep your application's user interface crisp and clear even on 125%–300% scaling without rewriting the code.