Zoom problems of Canvas and ScrollViewer
Hi all,
I'm developing a chart app using WPF, I met some problems during implementing zoom functionality, here is the details:
I put all elements I want to zoom in a canvas called ZoomCanvas, which itself is in another Canvas called RootCanvas, the chart Axis, titles are all in RootCanvas, too. Then I put RootCanvas in a ScrollViewer, something like this:
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Canvas Name="RootCanvas" Height="600" Width="800">
<Canvas Name="ZoomCanvas" Height="480" Width="680" >
<Canvas.RenderTransform>
<ScaleTransform x:Name="m_canvasTransform"/>
</Canvas.RenderTransform>
</Canvas>
<TextBlock/>... <Line/>
</Canvas>
</ScrollViewer>
What I want to achieve is to only zoom ZoomCanvas, without affect any other elements. From user's point of view, the render size of ZoomCanvas is fixed. I use RenderTransform to scale ZoomCanvas, it works, but the content will be rendered outside of the canvas original size. Actually the height and width of ZoomCanvas are not changed. How can I scale the canvas while keep it rendered in original size?
The second problem is related. Since RootCanvas's size are not changed, the parent ScrollViewer doesn't get notified to enable the scrollbar automatically. Should I manualy in the code compute the offset and increase the size of RootCanvas? Or is there any better or standard way to achieve this?
Any comment or suggestion will be highly appreciate, thanks in advance.

