carouselview无法以xamarin形式使用

时间:2018-07-07 10:07:40

标签: c# xaml xamarin xamarin.forms visual-studio-2017

在我的xamarin表单项目中,主页图像轮播正在运行中,但有两个轮播,但见证轮播在2天前已停止工作,这是见证xamarin表单项目的代码

.xaml文件代码:

<StackLayout Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4">
   <Label Text="Testimonials" FontSize="15" TextColor="#3a5370" FontFamily="OpenSansBold.ttf#OpenSansBold" HorizontalTextAlignment="Center"/>
   <forms:CarouselView x:Name="TestimonialSlider">
      <forms:CarouselView.ItemTemplate>
         <DataTemplate>
            <StackLayout Orientation="Vertical" HorizontalOptions="Center">
               <Label Text="{Binding testitext}" HorizontalTextAlignment="Center"/>
               <Label Text="{Binding owner}" HorizontalTextAlignment="Center" FontAttributes="Bold"/>
            </StackLayout>
         </DataTemplate>
      </forms:CarouselView.ItemTemplate>
   </forms:CarouselView>
</StackLayout>

xaml.cs文件代码:

public class testicar
{
    public string testitext { get; set; }
    public string owner { get; set; }
}

List<testicar> testimonial;

public HomePage()
{
    InitializeComponent();

    testimonial = new List<testicar>();

    testimonial.Add(new testicar
    {
        testitext = "hi",
        owner = "how are you ?"
    });

    testimonial.Add(new testicar
    {
        testitext = "hi",
        owner = "how are you ?"
    });

    testimonial.Add(new testicar
    {
        testitext = "hi",
        owner = "how are you ?"
    });

    TestimonialSlider.ItemsSource = testimonial;
}

1 个答案:

答案 0 :(得分:0)

应该有高度问题。您的内容与图片重叠。只是玩高并检查。应该可以。