引用:System.Windows.Controls.Toolkit
xmlns:mswindows="clr-namespace:Microsoft.Windows;assembly=System.Windows.Controls.Toolkit"
然后用ListBoxDragDropTarget套在ListBox外,并设置ItemsPanelTemplate。
----ListBoxDragDropTarget并不能作用于virtualized容器(ListBox的默认容器),所以必须改变ListBox的ItemsPanelTemplate容器,比如说像这样加个StackPanel进去取代virtualized默认容器即可 .
<toolKit:ListBoxDragDropTarget AllowDrop="True"> <ListBox x:Name="AcceptListBox" Height="200" Width="200" displayMemberPath="Name"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical"/> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> </toolKit:ListBoxDragDropTarget>
除了ListBoxDragDropTarget控件还有如下控件也支持这种效果:
ListBoxDragDropTarget[已实现]
TreeViewDragDropTarget -[实现Treeview拖拽]
DataGridDragDropTarget-[DataGrid控件支持]
DataPointSeriesDragDropTarget-[尚未测试.]
原文地址:http://www.cnblogs.com/chenkai/archive/2010/05/26/1744226.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。