This topic has not yet been rated - Rate this topic

IScrollInfo Interface

Represents the main scrollable region inside a ScrollViewer control.

Namespace:  System.Windows.Controls.Primitives
Assembly:  PresentationFramework (in PresentationFramework.dll)
public interface IScrollInfo

The IScrollInfo type exposes the following members.

  Name Description
Public property CanHorizontallyScroll Gets or sets a value that indicates whether scrolling on the horizontal axis is possible.
Public property CanVerticallyScroll Gets or sets a value that indicates whether scrolling on the vertical axis is possible.
Public property ExtentHeight Gets the vertical size of the extent.
Public property ExtentWidth Gets the horizontal size of the extent.
Public property HorizontalOffset Gets the horizontal offset of the scrolled content.
Public property ScrollOwner Gets or sets a ScrollViewer element that controls scrolling behavior.
Public property VerticalOffset Gets the vertical offset of the scrolled content.
Public property ViewportHeight Gets the vertical size of the viewport for this content.
Public property ViewportWidth Gets the horizontal size of the viewport for this content.
Top
  Name Description
Public method LineDown Scrolls down within content by one logical unit.
Public method LineLeft Scrolls left within content by one logical unit.
Public method LineRight Scrolls right within content by one logical unit.
Public method LineUp Scrolls up within content by one logical unit.
Public method MakeVisible Forces content to scroll until the coordinate space of a Visual object is visible.
Public method MouseWheelDown Scrolls down within content after a user clicks the wheel button on a mouse.
Public method MouseWheelLeft Scrolls left within content after a user clicks the wheel button on a mouse.
Public method MouseWheelRight Scrolls right within content after a user clicks the wheel button on a mouse.
Public method MouseWheelUp Scrolls up within content after a user clicks the wheel button on a mouse.
Public method PageDown Scrolls down within content by one page.
Public method PageLeft Scrolls left within content by one page.
Public method PageRight Scrolls right within content by one page.
Public method PageUp Scrolls up within content by one page.
Public method SetHorizontalOffset Sets the amount of horizontal offset.
Public method SetVerticalOffset Sets the amount of vertical offset.
Top

The IScrollInfo interface exposes access to methods that enable logical scrolling of child content as well as computing which child elements are visible. In addition, it defines properties used to define the scrollable region.

Logical scrolling enables scrolling to the next element in the logical tree. Physical scrolling, in contrast, scrolls content by a defined measurable increment in a specified direction. If you require physical scrolling instead of logical scrolling, wrap the host Panel element in a ScrollViewer and set the value of its CanContentScroll property to false.

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.


private void spLineUp(object sender, RoutedEventArgs e)
{
    ((IScrollInfo)sp1).LineUp();
}
private void spLineDown(object sender, RoutedEventArgs e)
{
    ((IScrollInfo)sp1).LineDown();
}


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Wrong example
the upper exemple gives an invalid cast exception