Reputation: 21
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?
Upvotes: 2
Views: 1466
Reputation: 16652
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.
Upvotes: 1