WPF以毫米为单位指定控件的长度 [英] WPF Specify controls' length in millimeters

查看:91
本文介绍了WPF以毫米为单位指定控件的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些天,我正在研究复杂的WPF应用程序.到目前为止,这是一个很好的经验.但是我陷入了困境.它是一个设计器应用程序,用户可以在画布上拖动自定义控件并设置其属性.当前,用户可以以cm,in,px和pt指定控件的长度.我需要让他们选择以毫米为单位指定控件的长度.

These days I am working on a complex WPF application. So far it has been a good experience. But I am stuck on a point. Its a designer application and users drag custom controls on a canvas and set their properties. Currently users can specify the control's length in cm, in, px and pt. I need to give them the option of specifying control's length in millimeters.

我知道WPF中的LengthConverter类,但是它没有给我们提供使用毫米作为单位的便利.这是为什么?Microsoft为什么不提供以毫米为单位指定控件长度的可能性?

I know of LengthConverter class in WPF but it does not give us the facility to use millimeters as unit. Why is that? Why would Microsoft not give the possibility of specifying lengths of controls in mm?

有哪些解决方法?

推荐答案

想知道是否由于明显的答案而未回答此问题...

Wondering if this question was left unanswered because of the obvious answer...

如果可以使用 cm 作为尺寸,则没问题.

If you can use cm as a size there is no problem.

要求以毫米为单位的所需大小,除以十,就可以了.

Ask for the desired size in mm, divide by ten and you're there.

Microsoft为什么不提供以mm为单位指定控件长度的可能性?

Why would Microsoft not give the possibility of specifying lengths of controls in mm?

也许是因为他们认为没有必要添加对10的所有倍数的支持?您可能还会问为什么他们不使用千分尺,毫米,十亿分之一米,米,十米,百米,公里...因为从cm的转换非常容易.

Maybe because they don't feel it's necessary to add support for all multiples of 10? You might as well ask why they don't use micrometers, millimetres, decimetres, meters, decameters, hectometres, kilometres... because the conversion from cm is so easy.

为了方便起见,即使转换系数很容易达到72,他们也使用英寸 pt.但这并不那么明显.

To wit, they do use inch and pt even though there's an easy conversion factor of 72. But that 's not as obvious.

这篇关于WPF以毫米为单位指定控件的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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