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.


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

  1: <Window x:Class="WpfScrollViewer.Window1"
  2:     xmlns=""
  3:     xmlns:x=""
  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>

Here is the output of this program.



Leave a Reply

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

You are commenting using your 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


%d bloggers like this: