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.05k stars 1.73k forks source link

.NET MAUI CollectionView does not reorder when grouped #13027

Open bladewolf55 opened 1 year ago

bladewolf55 commented 1 year ago

Description

CollectionView inherits from ReorderableItemsView, which itself has these two properties:

The purpose of CanMixGroups is to allow reordering of items between groups.

https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.controls.reorderableitemsview?view=net-maui-7.0

However, the Microsoft.Maui class Controls\src\Core\Handlers\Items\ReorderableItemsViewHandler.Windows.cs has this code:

void HandleDragItemsStarting(object sender, DragItemsStartingEventArgs e)
{
    // Built in reordering only supports ungrouped sources & observable collections.
    var supportsReorder = Element != null && !Element.IsGrouped && Element.ItemsSource is INotifyCollectionChanged;
    if (supportsReorder)
    {
        // The AllowDrop property needs to be enabled when we start the drag operation.
        // We can't simply enable it when we set CanReorderItems because the VisualElementTracker also updates this property.
        // That means the tracker can overwrite any set we do in UpdateCanReorderItems.
        // To avoid that possibility, let's force it to true when the user begins to drag an item.
        // Reset it back to what it was when finished.
        _trackerAllowDrop = ListViewBase.AllowDrop;
        ListViewBase.AllowDrop = true;
    }
    else
    {
        e.Cancel = true;
    }
}

The above clearly disallows (on Windows) reordering between groups, and I haven't found any CollectionView code that overrides this behavior.

What good is CanMixGroups if you . . . can't?

Steps to Reproduce

  1. Clone maui-samples repository
  2. Open 6.0/UserInterface/Views/CollectionViewDemos/
  3. Edit VerticalListGroupingPage.xaml
        <CollectionView ItemsSource="{Binding Animals}"
                        IsGrouped="true"
                        CanReorderItems="True"
                        CanMixGroups="True">
  4. Run Windows app, select Grouping Vertical list with DataTemplates

Expected: Reordering between groups Actual: No reordering at all

Link to public reproduction project repository

https://github.com/bladewolf55/CollectionViewGroupedNotOrdering.git

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

I was not able test on other platforms

Affected platform versions

Windows 11, Android 34

Did you find any workaround?

No response

Relevant log output

No response

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.

jinxinjuan commented 1 year ago

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on Windows and Android platform with sample project. maui-samples/7.0/UserInterface/Views/CollectionViewDemos at main · dotnet/maui-samples · GitHub

jari-schuurman commented 4 months ago

Any update on this?

williambohrmann3 commented 2 months ago

Why is this explicitly unsupported on Windows as shown in the code despite the property being publicly facing and available?