Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

I am unable to set the particular page in Carousel view

$
0
0

Hi, I am implemented the Carousel view using https://blog.xamarin.com/flip-through-items-with-xamarin-forms-carouselview/. And I am able to implement the Carousel,
**But My Problem I want to set the startup page while opening (I mean when page is loaded the carousel view should show 5th page or 4th index) **

Plugin Used
Xamarin.Forms.CarouselView (2.3.0-pre2)

What I tried
Case 1: I have used Data binding in xaml but it always showing first page or index of zero

Case 2: I have used Data binding from .cs file like CarouselView.ItemSource= Images; and CarouselView.Position=5; but is giving unhandled exception i.e, System.DivideByZeroException: Attempted to divide by zero.

Here is the Sample code

Case 1:

            <cv:CarouselView Position="{Binding Position, Mode=TwoWay}" ItemSelected="CarouselAlbumItems_ItemSelected" ItemsSource="{Binding AlbumItems}" x:Name="CarouselAlbumItems">
                <cv:CarouselView.ItemTemplate>
                    <DataTemplate>
                        <Grid  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Image x:Name="imgAlbumItemName" Grid.RowSpan="2" Aspect="AspectFit" IsVisible="{Binding IsImage}" >
                                <Image.Source>
                                    <UriImageSource Uri="{Binding AlbumItemPath}" CacheValidity="14" />
                                </Image.Source>
                            </Image>
                        </Grid>
                    </DataTemplate>
                </cv:CarouselView.ItemTemplate>
            </cv:CarouselView>

Case 2:

    protected  override void OnAppearing()
    {
        base.OnAppearing();
        CarouselAlbumItems.ItemsSource = selectedItem.AlbumItems;
        CarouselAlbumItems.Position = position;            
    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>