Skip to main content
.NET Framework Class Library
ScrollChangedEventArgs Class

Describes a change in the scrolling state and contains the required arguments for a ScrollChanged event.

Inheritance Hierarchy
SystemObject
   SystemEventArgs
     System.WindowsRoutedEventArgs
      System.Windows.ControlsScrollChangedEventArgs

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
Syntax
Public Class ScrollChangedEventArgs _
	Inherits [%$TOPIC/ms612667_en-us_VS_110_3_0_0_0_0%]
public class ScrollChangedEventArgs : [%$TOPIC/ms612667_en-us_VS_110_3_0_1_0_0%]
public ref class ScrollChangedEventArgs : public [%$TOPIC/ms612667_en-us_VS_110_3_0_2_0_0%]
type ScrollChangedEventArgs =  
    class 
        inherit [%$TOPIC/ms612667_en-us_VS_110_3_0_3_0_0%] 
    end

The ScrollChangedEventArgs type exposes the following members.

Properties
  NameDescription
Public property ExtentHeightGets the updated height of the ScrollViewer extent.
Public property ExtentHeightChangeGets a value that indicates the change in height of the ScrollViewer extent.
Public property ExtentWidthGets the updated width of the ScrollViewer extent.
Public property ExtentWidthChangeGets a value that indicates the change in width of the ScrollViewer extent.
Public property HandledGets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. (Inherited from RoutedEventArgs.)
Public property HorizontalChangeGets a value that indicates the change in horizontal offset for a ScrollViewer.
Public property HorizontalOffsetGets the updated horizontal offset value for a ScrollViewer.
Public property OriginalSourceGets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. (Inherited from RoutedEventArgs.)
Public property RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance. (Inherited from RoutedEventArgs.)
Public property SourceGets or sets a reference to the object that raised the event. (Inherited from RoutedEventArgs.)
Public property VerticalChangeGets a value that indicates the change in vertical offset of a ScrollViewer.
Public property VerticalOffsetGets the updated value of the vertical offset for a ScrollViewer.
Public property ViewportHeightGets the updated value of the viewport height for a ScrollViewer.
Public property ViewportHeightChangeGets a value that indicates the change in value of the viewport height for a ScrollViewer.
Public property ViewportWidthGets the updated value of the viewport width for a ScrollViewer.
Public property ViewportWidthChangeGets a value that indicates the change in viewport width of a ScrollViewer.
Top
Methods
  NameDescription
Public method Equals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCodeServes as the default hash function. (Inherited from Object.)
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Protected method InvokeEventHandlerPerforms proper type casting before invoking the type-safe ScrollChangedEventHandler delegate (Overrides RoutedEventArgsInvokeEventHandler(Delegate, Object).)
Protected method MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnSetSourceWhen overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. (Inherited from RoutedEventArgs.)
Public method ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
Examples

This example shows how to handle the ScrollChanged event of a ScrollViewer.

A FlowDocument element with Paragraph parts is defined in XAML. When the ScrollChanged event occurs due to user interaction, a handler is invoked, and text is written to a TextBlock indicating that the event has occurred.

<ScrollViewer Name="sv1" CanContentScroll="False" ScrollChanged="sChanged">

  <FlowDocument FontFamily="Arial" PageWidth="400">
    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
      laoreet dolore magna aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis nostrud exerci tation
      ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure.
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
      laoreet dolore magna aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis nostrud exerci tation
      ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure.
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
      laoreet dolore magna aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis nostrud exerci tation
      ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure.
    </Paragraph>


...


    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
      laoreet dolore magna aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis nostrud exerci tation
      ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure.
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
      laoreet dolore magna aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis nostrud exerci tation
      ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure.
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
      laoreet dolore magna aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis nostrud exerci tation
      ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure.
    </Paragraph>

  </FlowDocument>
</ScrollViewer>
Private Sub sChanged(ByVal sender As Object, ByVal args As ScrollChangedEventArgs)


    If (sv1.CanContentScroll = True) Then
        tBlock1.Foreground = System.Windows.Media.Brushes.Red
        tBlock1.Text = "ScrollChangedEvent just Occurred"
        tBlock3.Text = "ExtentWidth is now " + args.ExtentWidth.ToString()
        tBlock4.Text = "ExtentHeightChange was " + args.ExtentHeightChange.ToString()
        tBlock5.Text = "ExtentWidthChange was " + args.ExtentWidthChange.ToString()
        tBlock6.Text = "HorizontalOffset is now " + args.HorizontalOffset.ToString()
        tBlock7.Text = "VerticalOffset is now " + args.VerticalOffset.ToString()
        tBlock8.Text = "HorizontalChange was " + args.HorizontalChange.ToString()
        tBlock9.Text = "VerticalChange was " + args.VerticalChange.ToString()
        tBlock10.Text = "ViewportHeight is now " + args.ViewportHeight.ToString()
        tBlock11.Text = "ViewportWidth is now " + args.ViewportWidth.ToString()
        tBlock12.Text = "ViewportHeightChange was " + args.ViewportHeightChange.ToString()
        tBlock13.Text = "ViewportWidthChange was " + args.ViewportWidthChange.ToString()

    Else
        tBlock1.Text = "" 

    End If
private void sChanged(object sender, ScrollChangedEventArgs e)
{
    if (sv1.CanContentScroll == true)
    {
        tBlock1.Foreground = System.Windows.Media.Brushes.Red;
        tBlock1.Text = "ScrollChangedEvent just Occurred";
        tBlock2.Text = "ExtentHeight is now " + e.ExtentHeight.ToString();
        tBlock3.Text = "ExtentWidth is now " + e.ExtentWidth.ToString();
        tBlock4.Text = "ExtentHeightChange was " + e.ExtentHeightChange.ToString();
        tBlock5.Text = "ExtentWidthChange was " + e.ExtentWidthChange.ToString();
        tBlock6.Text = "HorizontalOffset is now " + e.HorizontalOffset.ToString();
        tBlock7.Text = "VerticalOffset is now " + e.VerticalOffset.ToString();
        tBlock8.Text = "HorizontalChange was " + e.HorizontalChange.ToString();
        tBlock9.Text = "VerticalChange was " + e.VerticalChange.ToString();
        tBlock10.Text = "ViewportHeight is now " + e.ViewportHeight.ToString();
        tBlock11.Text = "ViewportWidth is now " + e.ViewportWidth.ToString();
        tBlock12.Text = "ViewportHeightChange was " + e.ViewportHeightChange.ToString();
        tBlock13.Text = "ViewportWidthChange was " + e.ViewportWidthChange.ToString();
    }
    else
    {
        tBlock1.Text = "";
    }
Version Information

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.