WPF Drag and Drop - Get original source info from DragEventArgs
- by Quinn351
I am trying write Drag and Drop functionality using MVVM which will allow me to drag PersonModel objects from one ListView to another.
This is almost working but I need to be able to get the ItemsSource of the source ListView from the DragEventArgs which I cant figure out how to do.
private void OnHandleDrop(DragEventArgs e)
{
if (e.Data != null && e.Data.GetDataPresent("myFormat"))
{
var person = e.Data.GetData("myFormat") as PersonModel;
//Gets the ItemsSource of the source ListView
..
//Gets the ItemsSource of the target ListView and Adds the person to it
((ObservableCollection<PersonModel>)(((ListView)e.Source).ItemsSource)).Add(person);
}
}
Any help would be greatly appreciated.
Thanks!