ListView UWP Drag Reorder doesn't fire Drop events

大兔子大兔子 提交于 2020-01-04 07:01:16

问题


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" />

In Code behind:

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

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.

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

Anyone know what I am missing?


回答1:


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

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.

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.



来源:https://stackoverflow.com/questions/35465926/listview-uwp-drag-reorder-doesnt-fire-drop-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!