Friday, July 31, 2009

ScrollViewer control in Silverlight 3

ScrollViewer control in Silverlight 3

Imagine that you just clicked a picture with a digital camera or cellphone. Now you decide to create an image for it using the Image control of Silverlight 3. But if your image is really large (most cameras and cellphones these days offer great megapixel capabilities) then the Image control alone would not be sufficient to display the content of the picture. Because when the image is rendered, only part of it would be visible in the UI. To be able to see the image in its entirety, you need a control that can allow you to scroll, either horizontally, or vertically or in both directions. Luckily for you, such a control is provided by Silverlight 3 and is named as the ScrollViewer control.

This control in Silverlight 3 enables you to scroll through its child controls, which could be an Image or a TextBlock or any such UI control. The ScrollViewer control provides support to include a HorizontalScrollBar and/or a VerticalScrollBar. You can decide which ones to use by specifying the Visibility property of each. For example, HorizontalScrollBarVisibility if set to Visible indicates that the HorizontalScrollBar would be visible.

Create a Silverlight 3
application and drag and drop the ScrollViewer control from the Toolbox into your XAML code (between the Grid tags). Also drag and drop an Image control.

Configure the properties of the controls as shown below.

See full detail:

No comments: