我如何获得FrameworkElement的真实位置?

时间:2012-07-16 14:27:51

标签: c# .net wpf position frameworkelement

我正在用户控件内的椭圆中执行rotationTransformscaleTransform。 我已经尝试过了,但没有用。

Point myUiElementPosition = 
   ellipse.TransformToAncestor(this.Parent as Panel).Transform(new Point(0, 0));

我正在使用鼠标旋转对象,但上面的代码总是返回相同的值!

我做错了什么?我已经尝试将App.Current.MainWindow代替this.Parent as Panel

我也尝试使用this代替ellipse

帮助!

1 个答案:

答案 0 :(得分:0)

使用ellipse.Parent代替this.Parent。我希望这会有所帮助。