There's no "Scrolled" event on the ScrollViewer, but what you can do is two-way bind a property to VerticalOffset
. That lets you trigger an event/command from your view/viewmodel when the scroll changes.
Something like this:
<ScrollViewer VerticalOffset="{Binding VerticalOffset,Mode=TwoWay}" ...
And then in the data context:
public double VerticalOffset
{
get { return _verticalOffset; }
set
{
_verticalOffset = value;
// call "on scroll changed" actions here
}
}
private double _verticalOffset = 0;
how could I do it using different tools rather than ScrollViewer
You can of course make a scrolling menu using other approaches. I'll bet there is some nifty approach you could figure, using the WinRT transitions/animations stuff, but I'm not familiar enough with those to say. Here are some others (not sure which would be best/easiest for your scenario):
- Probably using
Canvas
would be a quick-and-dirty way to do it (just set up buttons that set offCanvas.Left
andCanvas.Top
animations). - Extending
ItemsControl
along with a customControlTemplate
would be a good approach if you want to create a re-usable component. - I like extending
Panel
, but you have to do the animations manually using aDispatcherTimer
, and you have to lay out the buttons yourself usingMeasure
andArrange
.