拖拽WPF DataGrid和WPF treeView [英] Drag Drop betwwen WPF DataGrid and WPF treeView

查看:85
本文介绍了拖拽WPF DataGrid和WPF treeView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,





我正在制作一个WPF应用程序,其中我有一个包含员工列表的数据网格。 />


在窗口的左边,我有一个树视图,显示所有部门和子部门。



我想要的是我在datagrid中选择一个雇员/行并将其拖到树视图的特定节点上,最后我得到我选择的行/行的数据,以便我可以将它们移动到选定的部门。但我无法得到如何在WPF数据网格中拖放的逻辑。请帮助

Hello,


I am making a WPF application , in which i have a datagrid which contains list of employees.

On the left of window i have a treeview which shows all departments & subdepartments.

What i want is that i select a employee / row in datagrid and drag it over to the specific node of treeview and finally i get the data of row/rows i selected so that i could move them to selected department. But i am unable to get logic on how to do drag n drop in WPF datagrid. Please help

推荐答案

拖动&放入WPF MVVM可能很难。

我使用这个库 GongSolutions.Wpf。 DragDrop库 [ ^ ]很不错试试看。

试一试,你可以在NuGet上找到它 https://www.nuget.org/packages/gong-wpf-dragdrop/ [ ^ ]



它适用于将ItemSource绑定到集合的任何WPF控件。



一些很好的例子:



在WPF中拖放 [ ^ ]
Drag & Drop in WPF an MVVM can be hard to do.
I use this library GongSolutions.Wpf.DragDrop library[^] it is nice and easy to work with.
Give it a try, you can find it on NuGet https://www.nuget.org/packages/gong-wpf-dragdrop/[^]

It will work on any WPF control that has bind an ItemSource to a collection.

Some good examples:

Drag and Drop in WPF[^]


请参考:

在WPF中拖放 [ ^ ]

拖放概述 [ ^ ]

在WPF中拖放 [ ^ ]

Drag&放入WPF ...端到端解释.. [ ^ ]
Please, refer this:
Drag and Drop in WPF[^]
Drag and Drop Overview[^]
Drag and Drop in WPF[^]
Drag & Drop in WPF ... Explained end to end ..[^]


这篇关于拖拽WPF DataGrid和WPF treeView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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