Skip to content

Commit bff6175

Browse files
kubafloPureWeen
authored andcommitted
[iOS]CarouselView Position Not Respected When Changing From Hidden to Visible in CV2 - fix (#29999)
* [iOS]CarouselView Position Not Respected When Changing From Hidden to Visible in CV2 - fix * Update CarouselViewUpdatePosition.xaml * Update CarouselViewUpdatePosition.xaml
1 parent 0e92b83 commit bff6175

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/Controls/src/Core/Handlers/Items2/iOS/CarouselViewController2.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,13 @@ async Task UpdateInitialPosition()
499499
return;
500500
}
501501

502+
if(!ItemsView.IsVisible)
503+
{
504+
// If the CarouselView is not visible we don't want to set the initial position
505+
// since it will be set when the CarouselView becomes visible
506+
return;
507+
}
508+
502509
if (ItemsSource is null)
503510
{
504511
return;

src/Controls/tests/TestCases.HostApp/Issues/CarouselViewUpdatePosition.xaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,29 @@
1212
BackgroundColor="Black"
1313
TextColor="White"
1414
Text="Tap the Button. If the item selected in the CarouselView is Item 4, the test has passed."/>
15-
<!-- This functionality failed in CarouselView2. Reference: https://github.com/dotnet/maui/issues/29309 -->
16-
<!-- TODO: Replace CarouselView1 with CarouselView once the issues mentioned in the GitHub issue are resolved. -->
17-
<local:CarouselView1
15+
<CarouselView
1816
x:Name="carousel"
1917
IsSwipeEnabled="True"
2018
Position="3"
2119
IsVisible="False">
22-
<local:CarouselView1.ItemTemplate>
20+
<CarouselView.ItemTemplate>
2321
<DataTemplate>
2422
<Label
2523
Text="{Binding}"
2624
FontSize="Large"
2725
HorizontalOptions="CenterAndExpand"/>
2826
</DataTemplate>
29-
</local:CarouselView1.ItemTemplate>
30-
<local:CarouselView1.ItemsSource>
27+
</CarouselView.ItemTemplate>
28+
<CarouselView.ItemsSource>
3129
<x:Array Type="{x:Type x:String}">
3230
<x:String>Item 1</x:String>
3331
<x:String>Item 2</x:String>
3432
<x:String>Item 3</x:String>
3533
<x:String>Item 4</x:String>
3634
<x:String>Item 5</x:String>
3735
</x:Array>
38-
</local:CarouselView1.ItemsSource>
39-
</local:CarouselView1>
36+
</CarouselView.ItemsSource>
37+
</CarouselView>
4038
<Button
4139
AutomationId="AppearButton"
4240
Text="Appear"

0 commit comments

Comments
 (0)