Question

I've got a Winforms property grid hosted inside a WindowsFormsHost. Everything works wonderfully until you change the DPI settings in windows, or use a monitor with a very high DPI.

When you do that, the property names start to overlap, it seems like it arranges the UI, and THEN re-sizes the font to accommodate for the high DPI. Very strange. This is what it looks like:

enter image description here

(Note how the value labels aren't "blown up" like the name labels?) I have tried everything I can think of that's related to DPI. Setting AutoScaleMode on the PropertyGrid, Removing property mappings from the host, Setting UseCompatibleTextRendering etc...

I've been browsing through the .NET source and there doesn't seem to be a way to set a different font for the names vs the values.

I have tried to reproduce this in an empty WPF application, but have been unable to do so. Anyone have any ideas? I've exhausted all of my resources and Google skills to no avail.

Thanks

Simon

Edit: Incase it's relevant, I set "Change the size of all items" under Control Panel -> Display to "Large - 150%". Using Windows 8 but have seen the issue on other platforms as well.

Was it helpful?

Solution

Turns out the thing that was causing DPI issues, was an instanciation of a System.Windows.Forms.WebBrowser, comment out / remove that one control from one of our user controls and voila, all is well.

This answers my question, my issue is resolved. Although I'm still very curious to find out why this happens. (Don't ask me how many hours I've spent grasping at straws before finding this)

I Might add that while this has definitely proven to be the source of my issue, I have not been able to reproduce it in a smaller application.

OTHER TIPS

I got the exact same problem - turns out the best way for me was to turn off DPI awareness in the application. And the best way to do that was to this the AssemblyInfo

[assembly: DisableDpiAwareness]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top