问题
I'm having a hard time solving an issue of mine, I'm literally going mad.
Here's the idea: I have two ListView elements, and I need to open a dialogue when an element drops from the first list onto the second, but I need both the information from the element being dropped and the element being added to fill in the dialogue.
The thing is, I can't even get the basic functionality right - and that is opening the dialogue on drop.
I'm going to learn the D&D technique from start to finish, but I quickly need a way to at least call the dialogue.
After writing and erasing some code the only thing I have left is the following:
private void lvListaRadnika_MouseDown(object sender, MouseButtonEventArgs e)
{
DragDrop.DoDragDrop(lvListaRadnika, presenter.Selected, DragDropEffects.None);
}
private void ListView_Drop(object sender, DragEventArgs e)
{
DodavanjeRezervacije dr = new DodavanjeRezervacije(new DodavanjeRezervacijePresenter(null,true));
dr.Show();
}
At this point I need something to happen and after that I'll see about adding all the necessary checks, feeding the dialogue with the data as well as adding an adorner.
If someone could explain as much as possible about drag and drop along the way I would highly appreciate it, but at this point I only really need this to fire up.
回答1:
Converting my comment into an answer:
You should really give a try to the Gong WPF Drag And Drop Framework. I helps do these kind of things in a really clean and nice (MVVM) way.
回答2:
I had answered a similar question where i have a sample project demo to drag drop between any two controls.
Just refer to the answer here and you can use that control.
来源:https://stackoverflow.com/questions/16530334/how-to-do-drag-and-drop-in-wpf-between-two-lists