如何在WPF之间拖放两个列表? [英] How to do Drag and Drop in WPF between two lists?

查看:110
本文介绍了如何在WPF之间拖放两个列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难解决我的一个问题,我真的生气了。

I'm having a hard time solving an issue of mine, I'm literally going mad.

这是一个想法:我有两个 ListView 元素,当元素从第一个列表中删除到第二个列表时,我需要打开一个对话框,但是我需要从元素被删除的信息和要添加的元素填充对话。

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.

我将从头到尾学习D&D技术,但我很快就需要一种方法来至少打电话给对话。

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();
    }

在这一点上,我需要一些事情发生,之后我会看到添加所有必要的检查,与数据对话以及添加一个adorner。

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.

推荐答案

将我的评论转换成答案:

Converting my comment into an answer:

您应该尝试尝试。我以一种非常干净,漂亮(MVVM)的方式帮助做这些事情。

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.

这篇关于如何在WPF之间拖放两个列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆