It's a quick step to surround a panel or control using the ScrollViewer. Perform the following steps to add a scrolling functionality to an image control:
- Inside the project, add an image named demoImage.jpg.
- Open the MainWindow.xaml file from Solution Explorer.
- Now replace the existing Grid with a ScrollViewer.
- Add an image pointing to the demoImage.jpg file, as follows:
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> <Image Source="demoImage.jpg" /> </ScrollViewer>
- Run the application and you will see the following window with an image inside a ScrollViewer:
- Use the scroll bars to scroll left-right and/or up-down to see the entire image.