Scrolling so smooth like the butter on a muffin [How to: Animate the Horizontal/VerticalOffset properties of a ScrollViewer]

This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of

See you there!

Comments (10)
  1. michaudv says:

    Why don’t you make a behavior of this? this way peoples working in blend can reuse it. Just an idea

  2. David Anson says:


    According to my current understanding of Blend Behaviors, I could not use them to add the writable DependencyProperty that’s necessary to get the desired animate-able behavior. If you know otherwise, a pointer to more information would be great!

    Either way, that doesn’t mean you can’t use this solution with Blend! 🙂 Once you’ve compiled ScrollViewerOffsetMediator into some assembly in your project, you should be able to drop it onto the XAML design surface just like any other element – and then hook it up via the standard Blend mechanisms, and everything should work just fine. Other than the code for ScrollViewerOffsetMediator, my sample is 100% XAML-based – no code required – so the general process should be pretty Blend-friendly.

    Hope this helps!

  3. SharpGIS says:

    I managed to convert this code to a "real" Blend behavior which cleans up the usage a lot (no need for the ScrollViewerOffsetMediator). I’ll try and blog it tonight.

    But basically it now looks like this:



            <behaviors:MouseScrollViewer />



  4. SharpGIS says:

    Inspired by your approach I blogged my ScrollViewer behavior here:

    I made a few changes to the animation. I only use EaseOut since this gave a better feel to it, and instead of using Grid.Loaded for triggering the storyboard I used the MouseWheel event.

  5. David Anson says:


    Great stuff! Loved the post and thanks very much for following up on this! 🙂

  6. WantsMoreSettlesForLess says:

    If the ScrollViewer was not created in xaml then, when this thing constructs, there is no ScrollViewer.

     public ScrollViewer ScrollViewer {

        get { return (ScrollViewer)GetValue(ScrollViewerProperty);

    returns null since there is no actual scrollviewer control when this runs.  FYI.

  7. David Anson says:


    The code you show is a DependencyProperty getter, not a constructor. It will return null until a value is set – which the example XAML does via a Binding/ElementName, but which could be done in code by setting the property.

    Hope this helps!

  8. Balint Farkas says:

    Thanks man, this just saved me hours and hours in a SL project.

  9. ismail karacan says:

    many thanks great stuff !

  10. Rich Jardine says:

    I am WPF newbie.  I was looking for an auto-scolling ScrollViewer for some dashboards I am porting to WPF from legacy Windows Forms apps.  I was playing wtih animations for a couple weeks before I found your solution.  Thank You! Thank You! Thank you for posting this solution!


Comments are closed.

Skip to main content