ListView UWP拖动重新排序不会触发Drop事件 [英] ListView UWP Drag Reorder doesn't fire Drop events

查看:98
本文介绍了ListView UWP拖动重新排序不会触发Drop事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在UWP项目中对ListView进行重新排序.

I am attempting to reorder a ListView in my UWP project.

     <ListView Grid.Row="1" Name="List" Margin="12, 0, 12, 0"
               ItemTemplate="{StaticResource ListDataTemplate}" 
               SelectionMode="None" IsItemClickEnabled="True" ItemClick="List_ItemClick" 
               AllowDrop="True" CanReorderItems="True" ReorderMode="Enabled"
               DropCompleted="List_DropCompleted" />

在后面的代码中:

    private void List_DropCompleted(UIElement sender,DropCompletedEventArgs args)
    {
        UseManualOrder = true;
    }

UI很棒.我可以通过单击鼠标并在手机上触摸并拖动来进行拖动和重新排序.但是,我无法在背后的代码中触发任何拖放事件.我试过了:DropCompleted;DragItemsCompleted.没有人会开火.我已经尝试了所有我能想到的.

The UI Works great. I can drag and reorder with mouse click and drag or touch and drag on phone. However, I cannot get any of the drag/drop events to fire in the code behind. I have tried: Drop; DropCompleted; DragItemsCompleted. None will fire. I have tried everything I can think of.

我在代码后面的其他事件(如List_ItemClick)运行正常.

My other events in code behind like List_ItemClick are working fine.

有人知道我想念什么吗?

Anyone know what I am missing?

推荐答案

我尝试过:掉落;DropCompleted;DragItemsCompleted.没有人会开火.

I have tried: Drop; DropCompleted; DragItemsCompleted. None will fire.

对其进行了测试,拖放事件 DragItemsCompleted事件可能会触发.使用这些事件时,需要为 ListView 启用 AllowDrop ="True" CanDragItems ="True" .

Tested it, Drop event and DragItemsCompleted event can get fire. When you use these events, you will need to enable AllowDrop="True" and CanDragItems="True" for your ListView.

还测试了 DropCompleted事件和其他控件,此事件暂时不会被触发.

Also tested DropCompleted event with other controls, this event won't be triggered for now.

但是此问题不会影响拖放实现,您可以参考官方的拖放示例,了解如何使它们在此示例中起作用.

But this problem will not affect the Drop and Drag implementation, you can refer to the official Drag and drop sample, see how to make them work in this sample.

这篇关于ListView UWP拖动重新排序不会触发Drop事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆