WPF DPI issues

走远了吗. 提交于 2020-01-10 20:08:12

问题


I have developed an application that looks great on my computer but when I install it on other computers with different resolutions and DPI settings, it looks terrible. Controls overlap eachother and it's just miserable. Does anyone have any suggestions on how to avoid this?


回答1:


There's no way for Windows to know the native DPI (Dots per inches) of your screen, since there's physically no way that the screen can tell it to the computer. This means that a lot of people will have DPI settings, that aren't the same as their monitors native DPI.

So- how does this fit into the whole "WPF used DIPs (Device independent pixels)"-debate? Well, for WPF to calculate how large to make a DIP, it needs 1 information and 1 invariant: It needs to know the resolution you're running (not a problem) and it needs for you to set your screen to its native DPI. If your screen it not set to the native DPI, pixels might be larger or smaller than they should, compared to the physical size of the screen.

It's quite hard to explain really, have a look at these blog posts: http://www.odewit.net/ArticleContent.aspx?id=WpfDpiScaling&lang=en&format=html http://blogs.microsoft.co.il/blogs/tomershamam/archive/2007/11/30/wpf-is-dpi-depended.aspx http://www.wpflearningexperience.com/?p=41 (Down right now :( )

In general, you should make your UI scalable with stuff like scrollbars, paging controls and the likes, to avoid overlaps :)



来源:https://stackoverflow.com/questions/1910314/wpf-dpi-issues

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!