简体   繁体   English

在Windows Phone 8.1 ListView中重新排序

[英]Reordering in Windows Phone 8.1 ListView

I have a Windows Phone 8.1 ListView . 我有一个Windows Phone 8.1 ListView I want to reorder the items in the ListView .I want to initiate the reorder mode on longpress, I can manage it by tapping in to the items Holding event and change the ListView s ReorderMode to Enabled . 我想重新排序的项目ListView 。我想发起长按的重新排序模式,我可以通过点击该物品管理其Holding的事件,改变ListView小号ReorderModeEnabled The ListView looks like this ListView看起来像这样

在此输入图像描述

1. Is there a way to "select" and item as ready to be dragged? 1.有没有办法“选择”和项目准备好被拖动? So the ListView looks like this? 那么ListView看起来像这样? I could not find any property or anything to make it "selected". 我找不到任何财产或任何东西使其“被选中”。 It would be much better for the user to have the item he initiates the reorder on selected. 对于用户来说,在他选择的情况下启动重新排序的项目会更好。

在此输入图像描述

2. Is there a way to know the user dropped the item to another places (did the reorder)? 2.有没有办法知道用户将物品丢弃到另一个地方(重新排序)? I thought I could accomplish it by using the DragOver or DragLeaving events on the ListView, but they are fired when the reorder mode is disabled, not when the item is dropped to another position. 我认为我可以通过在ListView上使用DragOverDragLeaving事件来完成它,但是在禁用重新排序模式时会触发它们,而不是在项目被放到另一个位置时触发它们。

3. Is there a way to make the gaps between the items in reorder mode smaller? 3.有没有办法让重新订购模式中的项目之间的差距变小? I found the ListViewItemReorderHintThemeOffset resource but changing it (directly or editing a style for ListViewItem ) does not make any change. 我找到了ListViewItemReorderHintThemeOffset资源,但更改它(直接或编辑ListViewItem的样式)不会进行任何更改。

1 and 2 : 1和2:

You need to capture the PointerPressed event of the ListItem, or in the DataTemplate of the ItemTemplate. 您需要捕获ListItem的PointerPressed事件,或者捕获ItemTemplate的DataTemplate。

Then set the ReorderMode to Enabled : 然后将ReorderMode设置为Enabled:

        if (ListView != null && ListView.ReorderMode != ListViewReorderMode.Enabled)
        {
            ListView.ReorderMode = ListViewReorderMode.Enabled;
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM