开发者

SL4: How do I change the scale w/o scrolling the canvas?

We have a large canvas contained in a scrollviewer. The user can move the canvas by dragging with the mouse, or using the scrollbars.

开发者_Python百科How can we change the zoom (scale) in the scrollviewer while keeping the current center point?

I think the issue is getting the correct CenterX and CenterY for the ScaleTransform:

        var st = MapCanvas.RenderTransform as ScaleTransform;
        if (null != st)
        {
            st.CenterX = point.X;
            st.CenterY = point.Y;
            st.ScaleX = st.ScaleY = scale;
        }

Thanks for any hints...


It's been a while since I looked at transforms, but you might want to try setting the RenderTransformOrigin of MapCanvas to new Point(0.5, 0.5) (or set it in XAML)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜