[FIXED] xamarin how to set carouselview currentpage on startup

Issue

hi im using this carouselview:
https://stackoverflow.com/a/64639210/18463835

and I want to set 3th page on carousel view home page when opening page but I can’t.
im tried this:

            MainPageCarouselView.CurrentItem = 2;

its not working. i have 5 pages now but i think all pages is 10+, i want set main carouselView item to center on first start, also set indicator view to center page.
my carouselView:

<CarouselView
  x:Name="MainPageCarouselView"
  IndicatorView="{x:Reference MainContentPageViewIndicatorView}"
  IsSwipeEnabled="True"
  ItemTemplate="{StaticResource MainContentPageViewSelector}"
  ItemsSource="{Binding _mainContentPageViewItemsSource}"
  Loop="True"
  PeekAreaInsets="35"/>
  
<IndicatorView
  x:Name="MainContentPageViewIndicatorView"
  Margin="0,50,0,80"
  HorizontalOptions="FillAndExpand"
  IndicatorColor="White"
  IndicatorsShape="Circle"
  SelectedIndicatorColor="Black"
  VerticalOptions="EndAndExpand"/>

now have 5 pages but its will 10+ and this is on center page
i want make this page on center

Solution

just set;

MainPageCarouselView.Position = 2;

Answered By – BySuspect

Answer Checked By – David Goodson (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published