I want to zoom image in a canvas control keeping center of canvas as origin .Initially I tried with Render transform it worked well,but scroll bars were not appearing after zoom.I googled about it and found that layout transform should be used for that purpose.My problem is I am getting the scroll bar after zoom now but zoom origin is at top left of canvas,how can I set it to center.
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Canvas x:Name="grdMain" RenderTransformOrigin="0.5,0.5">
<Image Source="{Binding BmpImageSource,UpdateSourceTrigger=PropertyChanged}" x:Name="TargetImage" >
</Image>
<!-- <Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="{Binding ScaleFactor}" ScaleY="{Binding ScaleFactor}" />
</TransformGroup>
</Canvas.RenderTransform>-->
<Canvas.LayoutTransform>
<TransformGroup>
<ScaleTransform ScaleX="{Binding ScaleFactor}" ScaleY="{Binding ScaleFactor}" />
</TransformGroup>
</Canvas.LayoutTransform>
</Canvas>
</ScrollViewer>
Some suggestions says to set centerX and centerY on layout transform but size of my application is dynamic and I might not fixed center point.
<ScaleTransform ScaleX="{Binding ScaleFactor}" ScaleY="{Binding ScaleFactor}"
CenterX="250" CenterY="250"/>