Silverlight’s Missing ScrollViewer .ScrollChanged Event

If you’ve worked with Silverlight’s ScrollViewer you may have noticed the ScrollChanged event is missing. It exists in WPF but Microsoft conveniently left it out in Silverlight. If you need to be notified of changes to the VerticalOffset or HorizontalOffset you can use a dependency property which listens to the change of Offset properties of the ScrollViewer.

<ScrollViewer  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" x:Name="ScrollSource">
     <Grid x:Name="grdTimeline" />
<TextBox Text="{Binding HorizontalOffset, ElementName=ScrollSource}" x:Name="ScrollListener" />

Then you can use the TextChanged event of your textbox as the ScrollChanged event of the ScrollViewer.

Private Sub ScrollListener_TextChanged(sender As Object, e As System.Windows.Controls.TextChangedEventArgs) Handles ScrollListener.TextChanged
End Sub

No Comments

You can leave the first : )

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Do the Math      

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: