dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.24k stars 1.76k forks source link

[Android][iOS] CollectionView.CanReorderItems does not work #13100

Open omghb opened 1 year ago

omghb commented 1 year ago

Description

The reorder feature of the CollectionView does not work on Android and iOS. But it works on Windows. See screen recording:

Issue-CanReorderItems

Steps to Reproduce

  1. Create new .NET MAUI App with .NET 7
  2. Replace content in MainPage.xaml with:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp1.MainPage">

    <Border Padding="10" StrokeThickness="2">
        <CollectionView x:Name="collectionView" CanReorderItems="True">
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <Border Padding="10" StrokeThickness="2" BackgroundColor="LightBlue">
                        <Label Text="{Binding}"/>
                    </Border>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </Border>

</ContentPage>
  1. Replace content in MainPage.xaml.cs with:
    
    using System.Collections.ObjectModel;

namespace MauiApp1;

public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); collectionView.ItemsSource = new ObservableCollection(new[] { "Bill", "Steve", "John" }); } }


### Link to public reproduction project repository

-

### Version with bug

7.0 (current)

### Last version that worked well

Unknown/Other

### Affected platforms

iOS, Android

### Affected platform versions

iOS 16, Android 13

### Did you find any workaround?

_No response_

### Relevant log output

```shell
Installed Workload Id      Manifest Version       Installation Source
---------------------------------------------------------------------
android                    33.0.4/7.0.100         VS 17.4.33213.308
maui-windows               7.0.52/7.0.100         VS 17.4.33213.308
maui-maccatalyst           7.0.52/7.0.100         VS 17.4.33213.308
maccatalyst                16.1.1477/7.0.100      VS 17.4.33213.308
maui-ios                   7.0.52/7.0.100         VS 17.4.33213.308
ios                        16.1.1477/7.0.100      VS 17.4.33213.308
maui-android               7.0.52/7.0.100         VS 17.4.33213.308
ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

mjsb212 commented 1 year ago

I have same problem! the drag events dont trigger the CollectionChanged notification - so nothing gets updated in the view after ReOrder

mjsb212 commented 1 year ago

Drag & Drop reorder is not working anymore to update views & that feature breaks entire application. is there a workaround??

mjsb212 commented 1 year ago

Does anyone know of a workaround for this issue or what is causing it? & Is this only happening in .Net 7? Been trying to solve this problem for a while now. On Android Stepping through ReorderableItemsViewAdapter.cs it seems INotifyCollectionChanged is not implemented? Am I missing something??

ysbakker commented 11 months ago

@mjsb212 stumbled upon this as I first thought this wasn't working too. But both platforms support this natively so I was confused as to why this would not work.

As it turns out, the behaviour is slightly different on iOS/Android vs windows. You actually have to kind of tap and hold the item for a little bit before it becomes 'draggable'. I did get this working on both iOS and Android in the .NET 8 MAUI version.