0

I've an ItemControl, which is bound to a sublist of ViewModel, so each ViewModel is displayed inside a StackPanel.

Some of those viewModel represents an "empty" slot, some of them represent a "filled" viewModel.

So I would like to be able to drag one "filled" slot over an empty slot, but I've no idea where to starts, and how to indicate it can be dropped or not.

I've found some things, but it was about moving one element of a listbox to another listbox by example, in my case I want to drop one element on another element, not sure where I should starts, any clues?

The example that were not about lists were all done in code behind, AND in directly in the usercontrol being moved, not the owner of thoses elements

J4N
  • 19,480
  • 39
  • 187
  • 340
  • I find it convenient to set up the drag/drop events via EventSetters in my ItemsControl's ItemContainerStyle. That saves trouble messing around trying to figure out what item the user is dragging over at the moment. Remember that when you remove/add/reorder items, you're doing that with item viewmodels in the ObservableCollection bound to ItemsControl.ItemsSource. This question is a bit broad, but it's not a silly question. Is there a better site for it? – 15ee8f99-57ff-4f92-890c-b56153 Aug 23 '19 at 13:38
  • Pretty much like all those examples you looked at. Top of my bing list is. https://stackoverflow.com/questions/3534958/itemscontrol-drag-and-drop You would set allowdrop and hook up a drop handler in the template for your "empty slot" item rather than the itemscontrol. – Andy Aug 23 '19 at 13:45

0 Answers0