WinRT 8.1 Phone - ListView reordering

后端 未结 2 1967
予麋鹿
予麋鹿 2021-01-13 14:44

I need to create a reorderable ListView in a Windows Phone 8.1 app created using WinRT. The XAML is the following (it binds to an ObservableDictionary in the codebehind):

相关标签:
2条回答
  • 2021-01-13 15:43

    It appears that the property CanReorderItems is not supported on Windows Phone 8.1.

    (I tried a simple example, and it does not work, and I could not find any combination that made it work as it does on Windows 8.1.)

    0 讨论(0)
  • 2021-01-13 15:45

    For WP you need to set ListViewBase.ReorderMode

    This is what works for me - no idea which properties are really necessary; ReorderMode is set in code behind:

    <ListView x:Name="fooListView"
              ItemsSource="{Binding barlist, Mode=OneWay}" 
              SelectionMode="None"                
              AllowDrop="True" CanDragItems="True" IsSwipeEnabled="True" />
    

    The ListViewBase.Reorder property is available only for Windows Phone, so if you have the XAML in a Shared part of a universal app, you need to set it using conditional compile like so:

    #if WINDOWS_PHONE_APP
                MainListView.ReorderMode =  ListViewReorderMode.Enabled;
    #endif
    
    0 讨论(0)
提交回复
热议问题