13

I am looking for a way to reorder the content (items) of a WPF WrapPanel via drag and drop. I just want to click on an item and drag it to a new position.

To my understanding this is a very common task and I wonder I someone already did this or has any idea how to implement this functionality.

I did a google search already but found nothing. Maybe it is more difficult than I expected.

4

2 回答 2

13

我编写了一个可能有帮助的库:默认行为是允许在同一控件内重新排序:

http://code.google.com/p/gong-wpf-dragdrop/

啊,我注意到您只是在谈论 WrapPanel:您需要将 ItemsControl 与 WrapPanel 一起使用:

<ItemsControl.ItemsPanel>
    <ItemsPanelTemplate>
        <WrapPanel />
    </ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
于 2010-01-21T11:23:26.903 回答
4

A wrap panel won't give you the functionality you are looking for since it is just for layout. Instead look at adding the drag and drop functionality to a ListBox and change the ItemsPanelTemplate of that ListBox to use a wrap panel.


于 2010-01-21T11:19:49.610 回答