0

我有这个功能:

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

    }

因此,右键单击网格 (N) 后,它会旋转到 90,但不是围绕光标位置(是的,在左角附近)。

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

4

1 回答 1

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;
}
于 2013-10-11T10:32:53.510 回答