Scenario: Windows Phone 7 application using MVVM. I have a ListBox that is bound to a collection of items from my ViewModel. The main usage of this view is to allow the user to re-order the items to his liking.
How do I implement this in WP7 ? The way I would like to do this would be to simply allow the user to drag items to the position he wants. Is there any built-in support for such a gesture ? (I haven't been able to find any).
As stated by AnthonyWJones the GesureListener is probably what you are looking for. I just wanted to add that you can use a FluidMoveBehavior for the list in order for the items to animate smoothly when the item order changes. In my opinion it gives a much improved user experience.
A fluid move behavior is simple enough to just "plug in" to your existing list, like this:
You could include in your project the Silverlight for Windows Phone Toolkit and then use the
GestureListener
to listen forDragStarted
,DragDelta
andDragComplete
events.This solution works really well
http://blogs.msdn.com/b/jasongin/archive/2011/01/03/wp7-reorderlistbox-improvements-rearrange-animations-and-more.aspx
It's a control you just drop into your app and you can simply enable drag handles and move around items in a ListBox.