且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

【WPF】拖拽ListBox中的Item

更新时间:2022-09-11 23:40:46

原文:【WPF】拖拽ListBox中的Item

整理了两个关于WPF拖拽ListBox中的Item的功能。项目地址 https://github.com/Guxin233/WPF-DragItemInListBox


需求一: 两个ListBox,拖拽其中一个ListBox的Item,放置到另一个ListBox中。参考 http://www.c-sharpcorner.com/uploadfile/dpatra/drag-and-drop-item-in-listbox-in-wpf/

【WPF】拖拽ListBox中的Item

右边ListBox2本来是空的,从左边ListBox1中拖拽了一个Item过去。


 

需求二:单个ListBox,拖拽Item,释放后Item插入到鼠标所在位置,使ListBox的Items排序发生改变。参考 https://***.com/questions/3350187/wpf-c-rearrange-items-in-listbox-via-drag-and-drop

【WPF】拖拽ListBox中的Item

本来Item排序是从1到6的,拖拽5号Item以改变它在列表中的排序位置。