Skip to content

SwipeGesture is not working on a listview/CollectionView #16624

@Symbai

Description

@Symbai

Description

Related to #8895 I still have the issue for more than 1 year where SwipeGesture is not working on a listview. My goal is that a user can swipe to the left and the swipe event should be raised. But I can swipe as many times as I want, nothing happens. The swipe event is never raised.

Steps to Reproduce

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="MauiApp1.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:MauiApp1">

    <ListView ItemsSource="{Binding Source={x:Static local:Bla.Instance}, Path=Items}">
        <ListView.GestureRecognizers>
            <SwipeGestureRecognizer Direction="Left" Swiped="SwipeGestureRecognizer_Swiped" />
        </ListView.GestureRecognizers>
    </ListView>

</ContentPage>
using System.Collections.ObjectModel;

namespace MauiApp1
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void SwipeGestureRecognizer_Swiped(object sender, SwipedEventArgs e)
        {
            var s = string.Empty; //Set a breakpoint on this line and it never get hit or do something else, still event is never raised
        }
    }

    public class Bla
    {
        public static Bla Instance { get; } = new Bla();

        public Bla()
        {
            for (int i = 0; i < 20; i++)
            {
                Items.Add($"Item {i}");
            }
        }

        public ObservableCollection<string> Items { get; } = new ObservableCollection<string>();

    }

}

Link to public reproduction project repository

Yes

Version with bug

7.0.49 (Edit: 01/02/2024 still bugged)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Pixel 5 - API 31

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions