Posted by: Zeeshan Amjad | January 29, 2010

Simple ScrollViewer Application


Today we are going to discuss one very simple application of Scroll View. Scroll view control provided the scrolling facility. Its class is inherited by ContentControl, so it means we can use all the control level features such as template, style etc with this.

Here is a class diagram of ScrollViewer.

ScrollViewer

This simple XAML program shows the usage of scroll viewer show the color of rainbow.

  1: <Window x:Class="WpfScrollViewer.Window1"
  2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4:     Title="Scroll Viewer" Height="300" Width="300">
  5:     <ScrollViewer HorizontalScrollBarVisibility="Visible" 
  6:                   VerticalScrollBarVisibility="Visible">
  7:         <StackPanel>
  8:             <Border Margin="5" Height="50" Background="Violet" CornerRadius="5"/>
  9:             <Border Margin="5" Height="50" Background="Indigo" CornerRadius="5"/>
 10:             <Border Margin="5" Height="50" Background="Blue" CornerRadius="5"/>
 11:             <Border Margin="5" Height="50" Background="Green" CornerRadius="5"/>
 12:             <Border Margin="5" Height="50" Background="Yellow" CornerRadius="5"/>
 13:             <Border Margin="5" Height="50" Background="Orange" CornerRadius="5"/>
 14:             <Border Margin="5" Height="50" Background="Red" CornerRadius="5"/>
 15:         </StackPanel>
 16:     </ScrollViewer>
 17: </Window>
 18: 

Here is the output of this program.

ScrollViewerOutput

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: