Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public static void MapPeekAreaInsets(CarouselViewHandler handler, CarouselView c
(handler.PlatformView as IMauiRecyclerView<CarouselView>).UpdateAdapter();
}

// TODO: Change the modifier to public in .NET 10.
internal static void MapLoop(CarouselViewHandler handler, CarouselView carouselView)
{
(handler.PlatformView as IMauiRecyclerView<CarouselView>).UpdateAdapter();
}

public static void MapPosition(CarouselViewHandler handler, CarouselView carouselView)
{
(handler.PlatformView as IMauiCarouselRecyclerView).UpdateFromPosition();
Expand Down
3 changes: 2 additions & 1 deletion src/Controls/src/Core/Handlers/Items/CarouselViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public CarouselViewHandler(PropertyMapper mapper = null) : base(mapper ?? Mapper
[Controls.CarouselView.PeekAreaInsetsProperty.PropertyName] = MapPeekAreaInsets,
[Controls.CarouselView.IsBounceEnabledProperty.PropertyName] = MapIsBounceEnabled,
[Controls.CarouselView.PositionProperty.PropertyName] = MapPosition,
[Controls.CarouselView.CurrentItemProperty.PropertyName] = MapCurrentItem
[Controls.CarouselView.CurrentItemProperty.PropertyName] = MapCurrentItem,
[Controls.CarouselView.LoopProperty.PropertyName] = MapLoop
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ void UnsubscribeCollectionItemsSourceChanged(IItemsViewSource oldItemsSource)

internal void UpdateLoop()
{
if (!InitialPositionSet)
{
return;
}
Comment thread
bhavanesh2001 marked this conversation as resolved.

if (ItemsView is not CarouselView carousel)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public CarouselViewHandler2(PropertyMapper mapper = null) : base(mapper ?? Mappe
[Controls.CarouselView.PositionProperty.PropertyName] = MapPosition,
[Controls.CarouselView.CurrentItemProperty.PropertyName] = MapCurrentItem,
[Controls.CarouselView.ItemsLayoutProperty.PropertyName] = MapItemsLayout,
[Controls.CarouselView.LoopProperty.PropertyName] = MapLoop
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ internal bool IsUpdating()
}
internal void UpdateLoop()
{
if (!InitialPositionSet)
{
return;
}

if (ItemsView is not CarouselView carousel)
{
return;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue29411.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Controls.TestCases.HostApp.Issues.Issue29411"
Title="Issue29411">
<ContentPage.Resources>
<x:Array x:Key="MyItems" Type="{x:Type x:String}">
<x:String>First</x:String>
<x:String>Second</x:String>
<x:String>Third</x:String>
</x:Array>
</ContentPage.Resources>
<VerticalStackLayout>
<CarouselView x:Name="cview" AutomationId="MauiCarouselView" HeightRequest="300" Loop="True" ItemsSource="{StaticResource MyItems}">
<CarouselView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<Grid VerticalOptions="Center" HorizontalOptions="Center">
<Border
Stroke="DarkGray"
StrokeThickness="2"
Background="LightBlue"
Padding="20"
HorizontalOptions="Center"
VerticalOptions="Center"
StrokeShape="RoundRectangle 12">
<Label Text="{Binding .}" FontSize="24" HorizontalOptions="Center" VerticalOptions="Center" />
</Border>
</Grid>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
<Button Text="Change Loop" AutomationId="MauiButton" Clicked="Button_Clicked" />
</VerticalStackLayout>
</ContentPage>
14 changes: 14 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue29411.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Controls.TestCases.HostApp.Issues;
[Issue(IssueTracker.Github, 29411, "[Android] CarouselView.Loop = false causes crash on Android when changed at runtime", PlatformAffected.All)]
public partial class Issue29411 : ContentPage
{
public Issue29411()
{
InitializeComponent();
}

private void Button_Clicked(object sender, EventArgs e)
{
cview.Loop = !cview.Loop;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#if !MACCATALYST //Appium Swipe is not working on MACCATALYST
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will take a look to it. Can you try to use the DragCoordinates method for Mac (with a compilation directive in the test)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, Will try that out. In my local machine , App.SwipeRightToLeft() is reducing the screen brightness.

Copy link
Copy Markdown
Contributor Author

@bhavanesh2001 bhavanesh2001 May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz I tried using App.DragCoordinates, but it doesn’t work as expected on MacCatalyst. It performs a one-finger drag, while CarouselView swipe requires a two-finger gesture on the touchpad to trigger scroll.

using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Tests.Issues;

public class Issue29411 : _IssuesUITest
{
public Issue29411(TestDevice device) : base(device)
{
}

public override string Issue => "[Android] CarouselView.Loop = false causes crash on Android when changed at runtime";

[Test]
[Category(UITestCategories.CarouselView)]
public void ChangingLoopToFalseShouldNotCrash()
{
App.WaitForElement("MauiButton");
App.Tap("MauiButton");
App.SwipeRightToLeft("MauiCarouselView");
App.WaitForElement("MauiCarouselView");
}
}
#endif