Silverlight 4.0 可拖动排序的ListBox

来源:互联网 发布:python rar压缩密码 编辑:程序博客网 时间:2024/05/17 01:37

 引用: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

0 0