I have a canvas in WPF which contains an image control as seen below
<Canvas x:Name="ImageContainer"
Background="Transparent"
Height="{Binding ElementName=panel2, Path=ActualHeight}"
Width="{Binding ElementName=panel2, Path=ActualWidth}"
>
<local:ZoomBorder
x:Name="pictureBox1Border"
MouseWheel="pictureBox1Border_MouseWheel"
PreviewMouseRightButtonDown="pictureBox1Border_PreviewMouseRightButtonDown"
MouseLeave="pictureBox1Border_MouseLeave"
MouseEnter="pictureBox1Border_MouseEnter"
ClipToBounds="True"
>
<Image x:Name="pictureBox1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
MouseDown="pictureBox1_MouseDown"
MouseMove="pictureBox1_MouseMove"
MouseRightButtonUp="pictureBox1_MouseRightButtonUp"
MouseLeftButtonUp="pictureBox1_MouseLeftButtonUp"
Width="{Binding Path=ActualWidth,ElementName=ImageContainer}"
Height="{Binding Path=ActualHeight,ElementName=ImageContainer}"
Stretch="Uniform"
/>
</local:ZoomBorder>
</Canvas>
I implemented this using some of the code from the answer in this answer by Wiesław Šoltés question.
Now I want to add a scrollviewer around the canvas so that when I zoom the image, I can scroll the image around. But it doesn't work. The height and width of the scrollbars remain the same even when I zoom image. Can anyone direct me on how to make scrollviewer work normally?