The ScrollViewer is a simple helper control that works with other elements. If you ever find yourself needing to scroll content, this is the control you are looking for. I am going to demonstrate this in Expression Blend. I have opened a project called AddScrollViewer. I am going to start by showing you one of the grouping features in Blend, I'll do that by opening GroupInBlend. Then I'll use my Mouse Wheel to zoom out. I have a column, a rectangle and a column of ellipses. I am going to select my rectangles and then I am going to use this feature called Grouping which allows me to place these rectangles into different panel containers.
I'll go over to my Objects and Timeline section, right-click and choose GroupInto. With this demo, I am going to choose to GroupInto>Grid. If you look in the option of Timeline you'll now see that there is a grid that contains the three rectangles. When it's time to take the rectangles out of the Grid, you can right-click and choose Ungroup. Let's do the same thing for the ellipses. I'll select the ellipses, right-click and I'll group these into a StackPanel.
I am going to use this feature to add a ScrollViewer to some content. I'll move over to MainPage.xaml, use my Mouse Wheel to zoom out. Here I have a grid that contains four pictures. The height of the grid is set to 1200 pixels, which is too high to see in this UI. Let me show you what I mean. I'll press F5 to run the application. As you can see at the bottom of the pictures are cut off.
I am going to add a ScrollViewer to make these viewable. I'll close the Browser, return to Blend, and I am going to group this grid into a ScrollViewer. And you can see that there is a scrollbar along the side. I am not going to get the behavior I want yet, because of the height of the ScrollViewer. I run the application. If I run this application you can see the scrollbar is here but it doesn't do me much good. I need to make the height of the ScrollViewer shorter in order to get the scrollbar to work.
Return back to Expression Blend, select the ScrollViewer, go over to the Property panel and type-in a different height, I'll pick 500 pixels, press Enter. That still doesn't look short enough, let's try 400 pixels, and then I'll run the application again and now I have success. You can scroll any content, I thought I'll show you one more example. In this XAML called BigButton.xaml, I have a giant button, that is 2600 pixels wide, I am going to group that into the ScrollViewer and then I am going to turn on the horizontal scrollbar.
To do that I am going to choose the ScrollViewer, I am going to use the Search feature in Blend. I am going to click at the top of my Property panel and I will type-in the word scroll. Now I am going to choose HorizontalScrollBarVisibility, it's a little bit hard to see because it's so narrow. HorizontalScrollBarVisibility, and I'll change that to Visible. If I were to run the application again I could scroll to the end of the button now. If I were to run the application now, I can scroll to the end of the button. And now you have seen how it adds scrolling to any UI element.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98069 Viewers
61 Video lessons · 85308 Viewers
71 Video lessons · 69354 Viewers
56 Video lessons · 101717 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Your file was successfully uploaded.