WPF似乎与分辨率无关 [英] WPF does not appear to be resolution independent

查看:253
本文介绍了WPF似乎与分辨率无关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是WPF中的基本概念之一是它与分辨率无关.这样,如果一个对象在一个分辨率下占据1英寸的正方形,那么在另一个分辨率下也将占据1英寸的正方形.

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.

我该如何真正使该决议独立?看起来像Windows窗体一样,它使用像素,并且随着像素密度的变化,图形实体的真实大小也随之变化.

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.

推荐答案

您可能会误解WPF对独立性"的定义. Charles Petzold的输入:

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:

一个WPF程序想要在屏幕上绘制标尺.画96张 每英寸的单位.

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

在所有这些情况下,对于任何特定机器,标尺都是 相同的尺寸,并且与标尺显示的尺寸相同 Microsoft Word.当然,尺子上的尺码会有所不同 不同的机器.将机器连接至投影仪,然后 尺子上的英寸更像脚!

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,来自链接的线程(重点是我的):

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

您不会以某种方式解决"用户玩游戏的困境 硬件设置太多,以致您的应用看起来不太正确. WPF在解决此问题上比以往任何时候都更加深入.

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.

这篇关于WPF似乎与分辨率无关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆