WPF does not appear to be resolution independent

吃可爱长大的小学妹 提交于 2019-12-25 01:28:05

问题


My understanding is that one of the fundamental concepts in WPF is that it is resolution independent. That if an object takes up a 1" square at one resolution it will also take up an 1" square on a different resolution.

I'm not sure if there are design considerations here, but this appears to be completely false. Whether it be a font, an image or some other visual entity, they are all physically smaller when on a higher resolution.

How can I truly make this resolution independent? It appears that like Windows Forms it uses pixels and as the pixel density changes so does the true size of the graphical entities.


回答1:


You may be misunderstanding WPF's definition of "independence". This subject is discussed in excellent detail in this MSDN forum thread, and includes input from Microsoft MVP Charles Petzold:

A WPF programs[sic] wants to draw a ruler on the screen. It draws 96 units per inch.

In all these cases, for any particular machine, the ruler is exactly the same size, and it's the same size as the ruler displayed by Microsoft Word. Of course the ruler is going to be different sizes on different machines. Connect the machine to an overhead projector and the inches on the ruler are more like feet!

In short, since the application can't be aware of the physical characteristics of your display device (how is it to know if a single pixel is a square micrometer or a square inch in physical size?), you can't make your application "truly" resolution-independent, not according to your definition.

Tim Dawson, from the linked thread (emphasis mine):

You're not going to somehow "fix" the dilemma of the user playing with the hardware settings so much that your app doesn't look quite right. WPF goes a lot further towards fixing this than anything has before, though.



来源:https://stackoverflow.com/questions/7275137/wpf-does-not-appear-to-be-resolution-independent

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