dotnet / docs-maui

This repository contains documentation for .NET Multi-platform App UI (MAUI).
https://docs.microsoft.com/dotnet/maui
Creative Commons Attribution 4.0 International
226 stars 198 forks source link

How to delete a ListView cell? #1010

Open mprogers opened 2 years ago

mprogers commented 2 years ago

Perhaps the second most important operation, after selecting a cell, is deleting it, but there is no mention here as to how to do that, and I haven't been able to find anything, anywhere in the docs that talks about backswipe. I can find third party components that (apparently) do this, if I'm willing to spend $1200 a year for the privilege, but a reference here as to how to do this - or if it is not possible, an observation that it is not - would be great.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

davidbritch commented 1 year ago

Hi @mprogers

There's a long back-story here. In Xamarin.Forms, until around v3/4 the control to display lists of data was the ListView. Then a CollectionView control was added that superseded ListView. CollectionView makes life a lot easier than ListView. The idea was that CollectionView would completely replace ListView, but for various reasons that never happened.

Both controls have made it into .NET MAUI, again for various reasons. The scenario you're describing would be far easier in a CollectionView - each item it displays can be a SwipeView, to reveal context items (see https://github.com/dotnet/maui-samples/tree/main/6.0/UserInterface/Views/CollectionViewDemos) such as delete. I'm not sure if rewriting to use a CollectionView is feasible for you at this stage, but that's certainly the way I'd go if possible.