【发布时间】:2021-02-11 06:21:54
【问题描述】:
我有一个 UWP XAML <ListView>,我希望用户通过拖放重新排列。 ListViewBase 上的The CanReorderItems property 提供了该功能,并且只需要几个属性:
<ListView ItemsSource="{x:Bind Items}"
CanReorderItems="True"
AllowDrop="True"
DragItemsStarting="ListView_DragItemsStarting"
DragItemsCompleted="ListView_DragItemsCompleted">
<!-- ... -->
</ListView>
这成功地让我在 ListView 中拖放项目并在 ItemsSource 上触发 CollectionChanged 事件(删除然后添加)。但是,它不会触发 DragItemsStarting 和 DragItemsCompleted 事件。
这些事件让我可以原子地处理拖动,而不是依赖来自ItemsSource 的两个CollectionChanged 事件。
如何让这些事件触发?
【问题讨论】:
标签: xaml listview uwp windows-runtime