Skip to content
Merged
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
6 changes: 4 additions & 2 deletions src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ public static UICollectionViewLayout CreateCarouselLayout(
NSCollectionLayoutDimension itemHeight = NSCollectionLayoutDimension.CreateFractionalHeight(1);
NSCollectionLayoutDimension groupWidth = NSCollectionLayoutDimension.CreateFractionalWidth(1);
NSCollectionLayoutDimension groupHeight = NSCollectionLayoutDimension.CreateFractionalHeight(1);
nfloat itemSpacing = 0;
NSCollectionLayoutGroup group = null;

var layout = new UICollectionViewCompositionalLayout((sectionIndex, environment) =>
Expand Down Expand Up @@ -324,7 +323,10 @@ public static UICollectionViewLayout CreateCarouselLayout(
}

var section = NSCollectionLayoutSection.Create(group: group);
section.InterGroupSpacing = itemSpacing;
if (itemsView.ItemsLayout is LinearItemsLayout linearItemsLayout)
{
section.InterGroupSpacing = (nfloat)linearItemsLayout.ItemSpacing;
}
section.OrthogonalScrollingBehavior = isHorizontal
? UICollectionLayoutSectionOrthogonalScrollingBehavior.GroupPagingCentered
: UICollectionLayoutSectionOrthogonalScrollingBehavior.None;
Expand Down
18 changes: 8 additions & 10 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25192.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,26 @@
xmlns:local="clr-namespace:Maui.Controls.Sample"
x:Class="Maui.Controls.Sample.Issues.Issue25192">
<Grid>
<!-- This functionality failed in CarouselView2. Reference: https://github.com/dotnet/maui/issues/27025 -->
<!-- TODO: Replace CarouselView1 with CarouselView once the issues mentioned in the GitHub issue are resolved. -->
<local:CarouselView1 Margin="2,9,2,20"
<CarouselView Margin="2,9,2,20"
HeightRequest="180"
Loop="False"
PeekAreaInsets="20"
VerticalOptions="End"
HorizontalScrollBarVisibility="Never">
<local:CarouselView1.ItemsSource>
<CarouselView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Item1</x:String>
<x:String>Item2</x:String>
<x:String>Item3</x:String>
</x:Array>
</local:CarouselView1.ItemsSource>
<local:CarouselView1.ItemsLayout>
</CarouselView.ItemsSource>
<CarouselView.ItemsLayout>
<LinearItemsLayout ItemSpacing="5"
Orientation="Horizontal"
SnapPointsAlignment="Center"
SnapPointsType="MandatorySingle"/>
</local:CarouselView1.ItemsLayout>
<local:CarouselView1.ItemTemplate>
</CarouselView.ItemsLayout>
<CarouselView.ItemTemplate>
<DataTemplate
x:DataType="{x:Null}">
<Border BackgroundColor="Red"
Expand Down Expand Up @@ -103,7 +101,7 @@
</Grid>
</Border>
</DataTemplate>
</local:CarouselView1.ItemTemplate>
</local:CarouselView1>
</CarouselView.ItemTemplate>
</CarouselView>
</Grid>
</ContentPage>
Loading