How to make items reorderable *using touch* in an UWP 10.0 XAML/C# project

时间:2015-08-14 22:56:19

标签: xaml windows-store-apps windows-10 uwp

According to the example on this page, the following code would enable reordering of the items in a ListView. Actually it does, but only using the mouse. If I put the window on my touchscreen and touch the items, it'll show the 'scroll failed' animation (move vertically then pop back) and items won't reorder. Any suggestions?

<ListView CanReorderItems="True" AllowDrop="True">
    <ListView.ItemTemplate>
        <DataTemplate><TextBlock Text="{Binding}"/></DataTemplate>
    </ListView.ItemTemplate>
    <x:String>One</x:String>
    <x:String>Two</x:String>
    <x:String>Three</x:String>
    <x:String>Four</x:String>
</ListView>

This is all in an UWP 10.0 project (frameworks: uap10.0), to be specific.

I'd hope this to work without having to write drag and drop code.

1 个答案:

答案 0 :(得分:0)

花了一个小时才继续前行,三小时后结束here试图解决另一个问题。

  

Tap&amp;按住,然后拖动以重新排序

斯科特用汉堡包做握把......不错的选择。提示是静态必须在列表中重新排序,能够“抓取”项目或重新排序可能无法正常工作,因为正在处理手势以执行其他操作。我的列表很短,但其中有复选框,可以选中/取消选中,之后你就无法重新排序。在图像中,列表比屏幕长。一旦它开始滚动,你就不能再重新排序了。

似乎我的手指太匆忙了。即使没有复选框改变状态或者问题的确切代码,我也似乎无法重新排序。只包含字符串。

非常满意这需要的代码量;)

Stolen from Scott Hanselmans Blog