maui icon indicating copy to clipboard operation
maui copied to clipboard

Swipe not working when SwipeView is used as base element

Open pekspro opened this issue 2 years ago • 6 comments

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 https://github.com/dotnet/maui/issues/6153.

Relevant log output

No response

pekspro avatar Apr 16 '22 06:04 pekspro

Verified this issue with Visual Studio Enterprise 17.3.0 Preview 1.0 [32414.199.main]. Repro on Android. Sample Project: 6154.zip

XamlTest avatar Apr 18 '22 02:04 XamlTest

On windows plataform this crash below happen :

image

RobertoGFilho avatar Apr 21 '22 20:04 RobertoGFilho

Perhaps related to #6018 where SwipeView is used as root element

davidortinau avatar Apr 30 '22 22:04 davidortinau

Tested in main branch and Windows in no longer crashing after merge https://github.com/dotnet/maui/issues/6018

jsuarezruiz avatar May 03 '22 15:05 jsuarezruiz

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.

ghost avatar Aug 30 '22 15:08 ghost

I've updated sample application to .NET 7. The same issue remains.

pekspro avatar Nov 11 '22 20:11 pekspro

Verified repro on Windows 11 with 17.6.0 Preview 7.0. Repro project MauiIssues-SwipeNotSupportedAsBaseInView.zip

Enbi-Zhang avatar May 12 '23 06:05 Enbi-Zhang