Occurs when changes are detected to the scrollbars position, extent, viewport size or visibility of the control.
Supported in Silverlight, Windows Phone 7
Syntax
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.
Example
Visual Basic | Copy 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);
} |
SilverlightCSharp | 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(((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);
} |
SilverlightVB | Copy 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
Requirements
Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also