WPF DataGrid中的常规DragDrop行为 [英] Generic DragDrop Behavior in WPF DataGrid

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

问题描述

我进行了行为拖放行为其中需要一个Collection(像ObservableCollection,LIst这样实现IList)

I made a Behavior Drag Drop Beahvior which take a Collection (Implementing IList like ObservableCollection,LIst)

及其正常工作...

但是如果我使用 CollectionViewSource.View (在Xaml绑定中),则行为失误...。

but if I Use CollectionViewSource.View (in the Xaml Binding), the behavior falis....

如何使此行为通用(就像不依赖于附加到DataGrid的数据源的类型一样)

How could I make this behavior Generic (LIke independent of type of DataSource attached to DataGrid)

即使我正在使用IList接口的方法(例如

Is it even possible as I am using methods for IList interface like

Insert(object item)


推荐答案

此问题已经有了开源解决方案,请参见 Wpf拖曳放弃行为。此行为将对任何ItemsControl实施拖放,它也应适用于datagrid。

This problem already has an open source solution, see Wpf Drag & Drop behaviour. This behavior will implement drag drop for any ItemsControl, it should work for datagrid too.

这篇关于WPF DataGrid中的常规DragDrop行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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