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

CarouselView has multiple items by default

$
0
0

I have created a CarouselView, base off of the Monkey example. Currently my app is, by default, showing as many items as it can stuff onto the screen. The CarouselView is within a StackLayout. I'd like the CarouselView to act like a CarouselPage, where I have the ItemTemplate displayed filling the rest of the screen, then I slide between views.

I read that there is a CarouselView Xaml property called "NumberOfSideItems", which states that the default value is 0, so that I should have only one CarouselView item on the screen at a time - but there is no NumberOfSideItems Xaml property for me.

Here is my Xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             xmlns:controls="clr-namespace:JetXamarin.Controls"
             x:Class="JetXamarin.Views.DictionaryPage">
    <ContentPage.Resources>
        <DataTemplate x:Key="ExampleTemplate">
            <StackLayout>
                <Frame HasShadow="True"
                       BorderColor="DarkGray"
                       CornerRadius="5"
                       HeightRequest="300"
                       HorizontalOptions="FillAndExpand"
                       VerticalOptions="FillAndExpand"
                       >
                    <StackLayout>
                        <Label Text="{Binding TextA}"/>
                        <Label Text="{Binding TextB}"/>
                        <Label Text="{Binding TextC}"/>
                    </StackLayout>
                </Frame>
            </StackLayout>
        </DataTemplate>

        <controls:ExampleDataTemplateSelector x:Key="ExampleSelector"
                                              Example="{StaticResource ExampleTemplate}"/>
    </ContentPage.Resources>
    <StackLayout Orientation="Vertical" HeightRequest="-1" WidthRequest="-1" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
        <StackLayout Orientation="Horizontal">
            <Button Text="Japanese"/>
            <Button Text="English"/>
        </StackLayout>
        <CarouselView
            ItemsSource="{Binding Examples}" 
            ItemTemplate="{StaticResource ExampleSelector}"
            ItemSizingStrategy="MeasureFirstItem"
            >
        </CarouselView>
    </StackLayout>
</ContentPage>

Thanks for the help!


Viewing all articles
Browse latest Browse all 91519


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