【问题标题】:Carousel view does not return anything轮播视图不返回任何内容
【发布时间】:2017-05-23 19:41:03
【问题描述】:

我正在我的项目中实现一个轮播,但我实现它的方式并没有给我任何回报,我的代码中出现了一些错误?我忘记了任何选择吗?参考 Xamarin.Forms.CarouselView 已经附上

OBS:我正在开发跨平台

           <?xml version="1.0" encoding="utf-8" ?>
         <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="Hanselman.Portable.Views.PodcastPage" Title="{Binding Title}"
         xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
         Icon="{Binding Icon}"  IsBusy="{Binding IsBusy}"
         xmlns:cv="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView">

<AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

    <StackLayout BackgroundColor="White" VerticalOptions="FillAndExpand">

        <cv:CarouselView x:Name="car" HeightRequest="200">
            <cv:CarouselView.ItemTemplate>
                <DataTemplate>
                    <StackLayout Orientation="Vertical">
                        <Image Aspect="AspectFit" Source="{Binding imgs}"/>
                    </StackLayout>
                </DataTemplate>
            </cv:CarouselView.ItemTemplate>
        </cv:CarouselView>
          </AbsoluteLayout>
    </ContentPage>

 public class Dados
    {
        public string imgs { get; set; }
    }

    public PodcastPage()
    {
        InitializeComponent();

        List<Dados> lista = new List<Dados>();

        lista.Add(new Dados
        {
            imgs = "car1.png",
        });

        lista.Add(new Dados
        {
            imgs = "car2.png",
        });

        lista.Add(new Dados
        {
            imgs = "car3.png",
        });

        car.ItemsSource = lista;
    }

【问题讨论】:

标签: xamarin xamarin.forms


【解决方案1】:
    <cv:CarouselView x:Name="MainCarouselView" HeightRequest="100">
            <cv:CarouselView.ItemTemplate>
                <DataTemplate>
                    <Label Text="jose" FontSize="50" TextColor="Black"/>
                </DataTemplate>
            </cv:CarouselView.ItemTemplate>
        </cv:CarouselView>

我尝试只使用内部标签并显示我的名字而不使用图像,即使它不会向我返回任何内容,但是当我移除轮播时它可以工作,看到我确认我的错误在我的轮播中,它不是图片问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-27
    • 2019-04-06
    • 2012-02-15
    • 2020-09-07
    • 2021-11-22
    • 2015-11-06
    相关资源
    最近更新 更多