如何在CarouselView-xamarin表单中删除项目之间的空间?
我想删除项目之间的空间
<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>
答案 0 :(得分:1)
只需将InterPageSpacing属性添加到CarouselView控件即可。此功能适用于此CarouselView插件github.com/alexrainman/CarouselView。您将像这样添加属性
<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>