How remove space between items in CarouselView-xamarin forms

How remove space between items in CarouselView-xamarin forms ?

I would like remove space between items, please

<control:CarouselView 
    x:FieldModifier="teste"
     ItemsSource="{Binding Itens}"
     AbsoluteLayout.LayoutFlags="All" 
    HeightRequest="150"
    WidthRequest="250"
     Position="{Binding Position}">
    <b:Interaction.Behaviors>
        <b:BehaviorCollection>
            <b:EventToCommand EventName="PositionSelected" Command="{Binding OnPositionSelectedCommand}" />
        </b:BehaviorCollection>
    </b:Interaction.Behaviors>
    <control:CarouselView.ItemTemplate>
        <DataTemplate >
            <ContentView >   
                <AbsoluteLayout  WidthRequest="50" HeightRequest="50">
                        <StackLayout  Padding="10,10,10,10" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0, 1, 1, 1" VerticalOptions="Center">
                            <Label Text="{Binding Titulo}" HorizontalTextAlignment="Center" TextColor="{StaticResource CadastroBackground}" FontSize="40" HorizontalOptions="CenterAndExpand" />
                        </StackLayout>
                    </AbsoluteLayout>
            </ContentView>
        </DataTemplate>
    </control:CarouselView.ItemTemplate>
</control:CarouselView>

enter image description here

Upvotes: 1

Views: 1958

Answers (1)

Mouse On Mars
Mouse On Mars

Reputation: 1132

Just add the InterPageSpacing attriubte to the CarouselView control. This works for this CarouselView plugin github.com/alexrainman/CarouselView. You would add the attribute like this

<control:CarouselViewControl 
    InterPageSpacing="0"
    ItemsSource="{Binding Itens}"
    AbsoluteLayout.LayoutFlags="All" 
    HeightRequest="150"
    WidthRequest="250"
    Position="{Binding Position}">
    <b:Interaction.Behaviors>
        <b:BehaviorCollection>
            <b:EventToCommand EventName="PositionSelected" Command="{Binding OnPositionSelectedCommand}" />
        </b:BehaviorCollection>
    </b:Interaction.Behaviors>
    <control:CarouselViewControl.ItemTemplate>
        <DataTemplate >
            <ContentView >   
                <AbsoluteLayout  WidthRequest="50" HeightRequest="50">
                        <StackLayout  Padding="10,10,10,10" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0, 1, 1, 1" VerticalOptions="Center">
                            <Label Text="{Binding Titulo}" HorizontalTextAlignment="Center" TextColor="{StaticResource CadastroBackground}" FontSize="40" HorizontalOptions="CenterAndExpand" />
                        </StackLayout>
                    </AbsoluteLayout>
            </ContentView>
        </DataTemplate>
    </control:CarouselViewControl.ItemTemplate>
</control:CarouselViewControl>

Upvotes: 1

Related Questions