Xamarin CarouselView不显示 [英] Xamarin CarouselView Not Displayed

查看:60
本文介绍了Xamarin CarouselView不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次尝试使用CarouselView,并对此感到惊讶.我的XAML定义如下

I am attempting to use CarouselView for the first time and is kind of struck with it. I have XAML defined as follows

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             prism:ViewModelLocator.AutowireViewModel="True"
             xmlns:cv="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView"
             x:Class="cSixty.Xam.Views.MainPage"
             Title="MainPage">
    <ContentPage.Content>
    <StackLayout>
        <Label Text="Name"  HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
        <cv:CarouselView ItemsSource="{Binding Zoos}">
            <cv:CarouselView.ItemTemplate>
                <DataTemplate>
                    <Label Text="{Binding Name}" />

                </DataTemplate>
            </cv:CarouselView.ItemTemplate>
        </cv:CarouselView>
    </StackLayout>
    </ContentPage.Content>
</ContentPage>

ViewModel的Collection定义如下.

The ViewModel has a Collection defined as follows.

    public MainPageViewModel()
    {
        Zoos = new ObservableCollection<Zoo>
            {
                new Zoo
                {
                    Name = "Woodland Park Zoo"
                },
                    new Zoo
                {
                    Name = "Cleveland Zoo"
                    },
                new Zoo
                {
                    Name = "Phoenix Zoo"
                }
            };

    }

将Zoo定义为

public class Zoo
{
    public string Name { get; set; }
}

我的问题是旋转木马没有出现.它全是空的.有人可以指导我吗?

My issue is that the Carousel just doesn't show up. Its all empty. Could someone guide me ?

推荐答案

最终使它工作了,只是想在其他人遇到相同情况时将其共享.

Finally got it working, just thought will share it in case someone else runs into same situation.

您还需要在Droid项目(或正在使用的任何平台)中安装Nuget软件包.以前,我只安装在便携式库中.

You need install the Nuget Package in your Droid Project (or whatever platform you are using) as well. Previously, I had installed in my Portable Library only.

这篇关于Xamarin CarouselView不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆