This now actually reorders the list. I’d originally intended the consumer to handle the reordering of the items but I’ve tried to get the control to reorder internally; to be honest it’s a bit of a hack as you never know what type of list is going to be bound to the listbox. I’ve create an ArrayList called internalList and do the reordering in that, reassigning it to the ListBox’s ItemsSource at the end.
If you click on an item and then click/drag the same item what you are dragging around is actually the item after the one you’d expect. It’s fine if you click/drag a new selection though; I’ll try and work that one out tonight.
Jim posted a comment asking if I had the source code for my ReorderableListBox sample. The answer was no, now it is yes. I’ve rewritten it against the RTM release of WPF, it still uses bits from Marcelo’s DragDropAdorner so thanks again to him.
You can get it from here.
The usual caveats apply, if you use it or modify it please keep the copyright notice with it and stick my blog address somewhere in your app. If it doesn’t work don’t come running to me because it only took
a couple of 4 hours 🙂