简体   繁体   中英

How to move List View Item between List Views with drag and drop when the List Views are created with a click of a button? UWP C#

I have an Universal Windows Platform Application in which there's an add button to create a List View, so there aren't any list views on start . You can later add List View Items to the created (added) List Views.

Here's the application with 2 ListViews added with the bottom add button and 1 ListViewItem added in each of them:

应用程序添加了 2 个 ListView,每个添加了 1 个 ListViewItem

I need to be able to move one List View Item from one created List View (List 0) to another one (List 1) using drag and drop.

How to handle the drag and drop events if the List Views are created in the app and are not on start?

You could set the CanDragItems property on the first ListView and the AllowDrop property on the second ListView. Then you need to handle the DragItemsStarting event in the first listview and handle the TargetListView_Drop event in the second listview.

There is an official UWP sample in Github: Drag and Drop . You could download it and try the sample to see how it is implemented. The listview in the sample does not define the listview item in the Xaml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM