maui
maui copied to clipboard
Swipe not working when SwipeView is used as base element
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).
Steps to Reproduce
- Create a new Maui application.
- 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>
- 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
Verified this issue with Visual Studio Enterprise 17.3.0 Preview 1.0 [32414.199.main]. Repro on Android. Sample Project: 6154.zip
On windows plataform this crash below happen :
Perhaps related to #6018 where SwipeView is used as root element
Tested in main branch and Windows in no longer crashing after merge https://github.com/dotnet/maui/issues/6018
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.
I've updated sample application to .NET 7. The same issue remains.
Verified repro on Windows 11 with 17.6.0 Preview 7.0. Repro project MauiIssues-SwipeNotSupportedAsBaseInView.zip