在光标位置周围旋转网格?

时间:2013-10-11 10:29:01

标签: c# wpf xaml windows-8

我有这个功能:

private void RightTap_Rotate(object sender, RightTappedRoutedEventArgs e)
    {
        var obj = (CompositeTransform)N.RenderTransform;
        obj.Rotation += 90;

    }

因此,右键单击Grid(N)后,它会旋转到90,但不会在光标位置周围(左边角落,是的)。

我需要使用什么来围绕光标旋转它?

1 个答案:

答案 0 :(得分:1)

设置转换的中心点:

private void RightTap_Rotate(object sender, RightTappedRoutedEventArgs e)
{
    var obj = (CompositeTransform)N.RenderTransform;
    Point cursorPos = Mouse.GetPosition(yourControl);
    obj.CenterX = cursorPos.X;
    obj.CenterY = cursorPos.Y;
    obj.Rotation += 90;
}