Skip to content

Swipe not working when SwipeView is used as base element #6154

@pekspro

Description

@pekspro

Description

If SwipeView is used as base element in a view, and this view is used in a DataTemplate source in a CollectionView swipe doesn't work, at least on Android (it triggers a crash on Windows).

Demo project

Steps to Reproduce

  1. Create a new Maui application.
  2. Add ItemView.xaml:
    <SwipeView 
                 xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 x:Class="MauiIssues.ItemView"
                 HeightRequest="80"        
        >

        <SwipeView.LeftItems>
            <SwipeItems>
                <SwipeItem Text="Favorite" BackgroundColor="LightGreen" />
                <SwipeItem Text="Delete" BackgroundColor="LightPink" />
            </SwipeItems>
        </SwipeView.LeftItems>

        <Label Text="Swipe me!" />
    </SwipeView>
  1. Add ItemView.cs:
    namespace MauiIssues
    {
        public partial class ItemView 
        {
            public ItemView()
            {
                InitializeComponent();
            }
        }
    }

4: Add CollectionView on MainPage:

    <CollectionView 
                x:Name="ItemsList"
                ItemSizingStrategy="MeasureFirstItem"
                >
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <r:ItemView />
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>

5: Initialize the list in the constructor:

	namespace MauiIssues;

	public partial class MainPage : ContentPage
	{
		public MainPage()
		{
			InitializeComponent();

			ItemsList.ItemsSource = new string[] { "Hello", "World" }; 
		}
	}

Run the application on Android and try to swipe.

Version with bug

Release Candidate 1 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 10, I was not able test on other platforms

Did you find any workaround?

Use SwipeView directly in the DataTemplate instead, like in this issue #6153.

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

area-controls-swipeviewSwipeViewfixed-in-8.0.0-rc.1.9171Look for this fix in 8.0.0-rc.1.9171p/2Work that is important, but is currently not scheduled for releaseplatform/androids/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions