是WPF窗口位置属性左侧,顶部,高度和宽度的会被双打? [英] Are the WPF Window position properties Left, Top, Height and Width ever actually Doubles?

查看:165
本文介绍了是WPF窗口位置属性左侧,顶部,高度和宽度的会被双打?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

位置属性,< A HREF =htt​​p://msdn.microsoft.com/en-us/library/system.windows.window.top.aspx相对=nofollow>页首,的高度和的宽度一个WPF窗口的是双打。然而,当<一href="http://stackoverflow.com/questions/4926201/make-a-window-draggable-within-a-certain-boundary-wpf/4929816#4929816">interacting与Windows邮件如 WM_MOVING WM_MOVE ,必须投双待href="http://msdn.microsoft.com/en-us/library/exx3b86w.aspx" rel="nofollow">整型的

The position properties Left, Top, Height and Width of a WPF Window are Doubles. However when interacting with windows messages like WM_MOVING and WM_MOVE, one must cast the double to an integral type.

这似乎还好我,因为所有的Windows通知似乎使用整型在其所有的位置参数,我想,这些消息是紧密联系在一起的WPF现在的位置属性。

This seemed okay to me since all the Windows Notifications seem to use integral types in all their positions arguments and I imagine that these messages are closely tied to the WPF postion properties.

所以,问题是,我是正确的这一假设,也可以在Windows的通知实际上是双打,最终也将是一些奇怪的副作用这个?

So the question is, am I correct in this assumption or can the windows notifications actually be doubles and eventually there's going to be some weird side-effect to this?

推荐答案

在WPF的窗口,这些属性实际上映射到窗口的位置,正如你指出(在Windows中)将映射到最终的整数值。

In WPF windows, these properties actually map to the Window's position, which, as you noted (in Windows) will map to an integer value eventually.

不过,它们定义为双打,这是很好的,因为他们干净映射到(从继承)其它FrameworkElement的特性,即:的 FrameworkElement.Width 。在一个窗口元素并利用双precision优势,因为它们可以设计成独立的分辨率,并允许任意缩放经由变换等

However, they're defined as doubles, which is nice as they map cleanly to (and inherit from) other FrameworkElement properties, ie: FrameworkElement.Width. Elements within a window do take advantage of double precision, as they're designed to be resolution independent and allow arbitrary scaling via a Transform, etc.

为使这些整数,该框架将不得不作出窗口不是一个FrameworkElement的,或为这些定义不同的属性,忽视了FrameworkElement的属性。无论哪种选择会引起混乱,并不是让这些双重价值差。此外,意识到这可能在未来使用子像素定位的实现 - 尽管在Windows API不支持现在的这个,这是理论上的可能(尽管可能性不大)可能在未来

To make these integers, the framework would have to make Window not be a FrameworkElement, or define separate properties for these, ignoring the FrameworkElement's properties. Either option would cause confusion and be worse than leaving these double values. Also, realize that it's possible for an implementation in the future to use sub-pixel positioning - though the Windows API does not support this now, it's theoretically possible (unlikely though) it could in the future.

这篇关于是WPF窗口位置属性左侧,顶部,高度和宽度的会被双打?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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