Tag: 变换

WPF客户端到屏幕点转换

我正在寻找一种转换方法,给出相对于屏幕上的Visual to Points的点数。 我找到了这个解决方案 http://social.msdn.microsoft.com/Forums/vstudio/en-US/b327c0bc-d27e-44fe-b833-c7db3400d632/how-to-get-control-location-in-screen-coordinate-system 我无法理解pointRoot和pointClient的不同,因为它们似乎始终相等: // […] // Translate the point from the visual to the root. GeneralTransform transformToRoot = relativeTo.TransformToAncestor(root); Point pointRoot = transformToRoot.Transform(point); // Transform the point from the root to client coordinates. Matrix m = Matrix.Identity; Transform transform = VisualTreeHelper.GetTransform(root); if (transform != null) m = Matrix.Multiply(m, transform.Value); Vector offset = […]

在WPF中动态更改旋转动画

我正在使用DoubleAnimation来动画RotationTransform的Angle属性。 每秒几次,我需要根据外部数据改变旋转速率,以便随着时间的推移旋转速度加快和/或减慢(平滑)。 我目前通过使用DoubleAnimation来实现这一点,DoubleAnimation从持续时间为X,然后每秒数次,从0.0到360.0永久重复: 从外部数据中获取新值 将DoubleAnimation上的速率修改为该值 再次将DoubleAnimation重新应用于Angle属性 注意:我确实发现我必须将动画上的To和From属性更改为“当前角度”和“当前角度+ 360” – 幸运的是我RotationTransform没有角度> 360度的麻烦 – 以防止开始旋转从零角度再次。 我的问题是:这是否合理? 它似乎并非如此。 在旋转变换上不断将新的DoubleAnimations应用于Angle属性似乎是错误的 – 有点像我让WPF为旋转设置动画,而我自己动画旋转速度。 有没有更好的办法?

转换后获取元素位置

我有一个UIElement,它上面进行了各种转换(缩放和翻译)。 有没有办法在转型后获得UIElement的位置? 我尝试了GetValue(Canvas.TopProperty)但它没有改变它的加载方式。 我必须遗漏一些明显但不确定的东西。 (我正在使用silverlight)