LEADTOOLS WPF and Silverlight (Leadtools.Windows.Controls assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
ScrollChanged Event
See Also 
Leadtools.Windows.Controls Namespace > ImageViewer Class : ScrollChanged Event



Occurs when changes are detected to the scrollbars position, extent, viewport size or visibility of the control. Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public Event ScrollChanged As EventHandler(Of ImageViewerScrollChangedEventArgs)
Visual Basic (Usage)Copy Code
Dim instance As ImageViewer
Dim handler As EventHandler(Of ImageViewerScrollChangedEventArgs)
 
AddHandler instance.ScrollChanged, handler
C++/CLI 
public:
event EventHandler<ImageViewerScrollChangedEventArgs^>^ ScrollChanged

Event Data

The event handler receives an argument of type ImageViewerScrollChangedEventArgs containing data related to this event. The following ImageViewerScrollChangedEventArgs properties provide information specific to this event.

PropertyDescription
Handled (Inherited from System.Windows.RoutedEventArgs) 
HorizontalChange Gets a value that indicates the change in horizontal offset for a ImageViewer or RasterImageViewer. Supported in Silverlight, Windows Phone 7
HorizontalOffset Gets the updated horizontal offset value for a ImageViewer or RasterImageViewer. Supported in Silverlight, Windows Phone 7
OriginalSource (Inherited from System.Windows.RoutedEventArgs) 
RoutedEvent (Inherited from System.Windows.RoutedEventArgs) 
Source (Inherited from System.Windows.RoutedEventArgs) 
VerticalChange Gets a value that indicates the change in vertical offset for a ImageViewer or RasterImageViewer. Supported in Silverlight, Windows Phone 7
VerticalOffset Gets the updated vertical offset value for a ImageViewer or RasterImageViewer. Supported in Silverlight, Windows Phone 7

Example

Visual BasicCopy Code
Public Sub ImageViewer_ScrollChanged(ByVal viewer As ImageViewer)
    If Not viewer.Source Is Nothing Then
        ' Scroll to the image center
        AddHandler viewer.ScrollChanged, AddressOf viewer_ScrollChanged
        viewer.ScrollViewer.ScrollToHorizontalOffset(viewer.Source.Width / 2)
        viewer.ScrollViewer.ScrollToVerticalOffset(viewer.Source.Height / 2)
        RemoveHandler viewer.ScrollChanged, AddressOf viewer_ScrollChanged
    End If
End Sub

Private Sub viewer_ScrollChanged(ByVal sender As Object, ByVal e As ImageViewerScrollChangedEventArgs)
    Dim s As String = String.Format("HorizontalOffset : {0}, VerticalOffset : {1}", e.HorizontalOffset, e.VerticalOffset)
    MessageBox.Show(s)
End Sub
C#Copy Code
public void ImageViewer_ScrollChanged(ImageViewer viewer)
{
   if (viewer.Source != null)
   {
      // Scroll to the image center
      viewer.ScrollChanged += new EventHandler<ImageViewerScrollChangedEventArgs>(viewer_ScrollChanged);
      viewer.ScrollViewer.ScrollToHorizontalOffset(viewer.Source.Width / 2);
      viewer.ScrollViewer.ScrollToVerticalOffset(viewer.Source.Height / 2);
      viewer.ScrollChanged -= new EventHandler<ImageViewerScrollChangedEventArgs>(viewer_ScrollChanged);
   }
}

void viewer_ScrollChanged(object sender, ImageViewerScrollChangedEventArgs e)
{
   string s = string.Format("HorizontalOffset : {0}, VerticalOffset : {1}", e.HorizontalOffset, e.VerticalOffset);
   MessageBox.Show(s);
}
SilverlightCSharpCopy Code
public void ImageViewer_ScrollChanged(ImageViewer viewer)
{
   if (viewer.Source != null)
   {
      // Scroll to the image center
      viewer.ScrollChanged += new EventHandler<ImageViewerScrollChangedEventArgs>(viewer_ScrollChanged);
      viewer.ScrollViewer.ScrollToHorizontalOffset(((BitmapSource)viewer.Source).PixelWidth/ 2);
      viewer.ScrollViewer.ScrollToVerticalOffset(((BitmapSource)viewer.Source).PixelHeight / 2);
      viewer.ScrollChanged -= new EventHandler<ImageViewerScrollChangedEventArgs>(viewer_ScrollChanged);
   }
}

void viewer_ScrollChanged(object sender, ImageViewerScrollChangedEventArgs e)
{
   string s = string.Format("HorizontalOffset : {0}, VerticalOffset : {1}", e.HorizontalOffset, e.VerticalOffset);
   MessageBox.Show(s);
}
SilverlightVBCopy Code
Public Sub ImageViewer_ScrollChanged(ByVal viewer As ImageViewer)
   If Not viewer.Source Is Nothing Then
      ' Scroll to the image center
      AddHandler viewer.ScrollChanged, AddressOf viewer_ScrollChanged
      viewer.ScrollViewer.ScrollToHorizontalOffset((CType(viewer.Source, BitmapSource)).PixelWidth / 2)
      viewer.ScrollViewer.ScrollToVerticalOffset((CType(viewer.Source, BitmapSource)).PixelHeight / 2)
      RemoveHandler viewer.ScrollChanged, AddressOf viewer_ScrollChanged
   End If
End Sub

Private Sub viewer_ScrollChanged(ByVal sender As Object, ByVal e As ImageViewerScrollChangedEventArgs)
   Dim s As String = String.Format("HorizontalOffset : {0}, VerticalOffset : {1}", e.HorizontalOffset, e.VerticalOffset)
   MessageBox.Show(s)
End Sub

Remarks

This event is raised if any action through user interaction or programmatically that cause the scrollbars position, extent, view port size or visibility of the control.

Requirements

Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also