Scrolls down within content after a user clicks the wheel button on a mouse.
Assembly: PresentationFramework (in PresentationFramework.dll)
This example shows how to scroll content by using the IScrollInfo interface.
The following example demonstrates the features of the IScrollInfo interface. The example creates a StackPanel element in Extensible Application Markup Language (XAML) that is nested in a parent ScrollViewer. The child elements of the StackPanel can be scrolled logically by using the methods defined by the IScrollInfo interface and cast to the instance of StackPanel (sp1) in code.
<Border BorderBrush="Black" Background="White" BorderThickness="2" Width="500" Height="500"> <ScrollViewer Name="sv1" CanContentScroll="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible"> <StackPanel Name="sp1"> <Button>Button 1</Button> <Button>Button 2</Button> <Button>Button 3</Button> <Button>Button 4</Button> <Button>Button 5</Button> <Rectangle Width="700" Height="500" Fill="Purple"/> <TextBlock>Rectangle 1</TextBlock> <Rectangle Width="700" Height="500" Fill="Red"/> <TextBlock>Rectangle 2</TextBlock> <Rectangle Width="700" Height="500" Fill="Green"/> <TextBlock>Rectangle 3</TextBlock> </StackPanel> </ScrollViewer> </Border>
Each Button in the XAML file triggers an associated custom method that controls scrolling behavior in StackPanel. The following example shows how to use the LineUp and LineDown methods; it also generically shows how to use all the positioning methods that the IScrollInfo class defines.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.