为什么所有仓位/尺寸都是双重格式? [英] Why all positions/sizes are in double format?

查看:161
本文介绍了为什么所有仓位/尺寸都是双重格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我会说坐标是基于像素。很容易理解(10,10)处的像素或100像素的宽度。

Basically, I would say that coordinates are "pixel-based". It is easy to understand a pixel at (10,10) or a width of 100 pixels.

但是因为位置和大小是双重格式,所以你可以有一个大小为100.6,位置为(10.1,50.9)。十进制值对位置/大小有影响吗?

But because positions and sizes are in double format, you can have a size of 100.6 and a position at (10.1,50.9). Does the decimal value have an impact on position/size?

事实上,我通过计算点来生成自定义路径。一些点几乎相等,例如1.9999999和2.000000。首先,我想围绕所有点,但我确定在xaml(1.99和2.00,是同样的点?)的影响。

In fact, I generate a custom path by calculating points. Some points are nearly equals such as 1.9999999 and 2.000000. At first, I would like to round all points but I am sure of the impact in xaml (1.99 and 2.00, is it the same point ?).

推荐答案

不,WPF位置和大小不是基于像素的,而是基于单位。

No, WPF positions and size are not pixel based, but "unit" based.

事实上,设置为96dpi。
但是,如果您将屏幕设置为120 dpi,例如,1个单位将等于1,25像素。

In fact, 1 unit equals 1 pixel when your scren is set to 96 dpi. But if you set up your screen to 120 dpi for example, 1 unit will equals 1,25 pixel.

直接的好处是,您的应用程序将适合更容易比窗口应用程序更高的分辨率。

The direct benefits is that your applications will fit easier than windows forms apps to higher scale resolutions.

FrameworkElement.Height属性


此值解释为

This value is interpreted as a device-independent unit (1/96th inch) measurement.

最后,建议您舍入值。不是出于技术原因,而是为了使XAML标记更易读和自然。

To conclude, I would suggest you to round values. Not for technical reasons, but to make the XAML markup more readable and "natural".

这篇关于为什么所有仓位/尺寸都是双重格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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