【问题标题】:How remove space between items in CarouselView-xamarin forms如何删除 CarouselView-xamarin 表单中项目之间的空间
【发布时间】:2019-01-07 15:04:38
【问题描述】:

如何去除 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>

【问题讨论】:

  • 欢迎来到 StackOverflow。您可以使用属性 InterPageSpacing 控制页面之间的空间。将其设置为零,这应该可以解决您的问题
  • 是的,但是我在哪里使用该属性?

标签: xamarin.forms


【解决方案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>

【讨论】:

  • 不幸的是我试过了,它不能识别为 carouselView 的属性。
  • 谢谢,我会继续找的。​​span>
  • 你可能想使用这个支持 InterPageSpacing 的插件github.com/alexrainman/CarouselView。如果我没记错的话,这个插件应该会成为 Xamarin.Forms 中的新标准 CarouselView
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-03-26
  • 1970-01-01
  • 2017-01-27
  • 2021-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多