LEADTOOLS WPF and Silverlight (Leadtools.Windows.Controls assembly)
LEAD Technologies, Inc

ScrollChanged Event

Example 





Occurs when changes are detected to the scrollbars position, extent, viewport size or visibility of the control. .NET support Silverlight support
Syntax
'Declaration
 
Public Event ScrollChanged As EventHandler(Of ImageViewerScrollChangedEventArgs)
'Usage
 
Dim instance As ImageViewer
Dim handler As EventHandler(Of ImageViewerScrollChangedEventArgs)
 
AddHandler instance.ScrollChanged, handler
add_ScrollChanged(function(sender, e))
remove_ScrollChanged(function(sender, e))

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. .NET support Silverlight support
HorizontalOffset Gets the updated horizontal offset value for a ImageViewer or RasterImageViewer. .NET support Silverlight support
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. .NET support Silverlight support
VerticalOffset Gets the updated vertical offset value for a ImageViewer or RasterImageViewer. .NET support Silverlight support
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.

Example
Copy CodeCopy 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
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);
}
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);
}
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
Requirements

Target Platforms: 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

See Also

Reference

ImageViewer Class
ImageViewer Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.