ARTICLE

How to create ScrollViewer in WPF

Posted by Manish Tewatia Articles | WPF using VB.NET August 30, 2010
In this article you will learn how to create ScrollViewer in WPF.
 
Reader Level:

ScrollViewer: In WPF scrolling or you can say the ScrollViewer is used when we want to fit the large amounts of content in a limited amount of space. The ScrollViewer control provides a convenient way to enable scrolling of content in WPF. ScrollViewer encapsulated the ScrollBars within it and displays it whenever it is required. As the ScrollViewer implements IScrollInfo is the main scrolling area inside the scrollviewer. ScrollViewer also responds to mouse and keyboard commands.

Example of ScrollViewer

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <ScrollViewer>
        <StackPanel>
            <Label>Which color you want</Label>
            <Button>Red</Button>
            <Button>Blue</Button>
            <Button>Pink</Button>
            <Button>Green</Button>
            <Button>Black</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
            <Button>Pink</Button>
        </StackPanel>        
   
</ScrollViewer>
</Window>

Output window

 scroll.gif

Conclusion

Hope this article helps you to learn ScrollViewer in WPF.

share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor