繁体   English   中英

轮播视图未显示

[英]Carousel View not showing

我创建了CarouselPage,但是我需要CarouselView,因此可以在页面上添加其他控件。 由于某种原因,什么也没有出现。 不知道我在想什么。

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

    public ObservableCollection<Zoo> Zoos { get; set; }

    public PlayKeySound()
    { 
        Zoos = new ObservableCollection<Zoo>
        {
            new Zoo
            {
                ImageUrl = "http://content.screencast.com/users/JamesMontemagno/folders/Jing/media/23c1dd13-333a-459e-9e23-c3784e7cb434/2016-06-02_1049.png",
                Name = "Woodland Park Zoo"
            },
            new Zoo
            {
                ImageUrl =    "http://content.screencast.com/users/JamesMontemagno/folders/Jing/media/6b60d27e-c1ec-4fe6-bebe-7386d545bb62/2016-06-02_1051.png",
                Name = "Cleveland Zoo"
                },
            new Zoo
            {
                ImageUrl = "http://content.screencast.com/users/JamesMontemagno/folders/Jing/media/e8179889-8189-4acb-bac5-812611199a03/2016-06-02_1053.png",
                Name = "Phoenix Zoo"
            }
        };

        InitializeComponent();

        carousel.ItemsSource = Zoos;
    }

XAML部分:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    xmlns:control="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView"
    x:Class="keysound.PlayKeySound"
    x:Name="devicePage"
    BackgroundColor="Gray" >
<ContentPage.Content>
    <StackLayout  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
        <control:CarouselView x:Name="carousel" >
            <control:CarouselView.ItemTemplate>
                <DataTemplate> 
                        <Label Text="{Binding Name}"/>
                </DataTemplate>
            </control:CarouselView.ItemTemplate>
        </control:CarouselView>
    </StackLayout>

</ContentPage.Content>

这只是测试轮播视图的测试代码。

我能够运行您的代码并查看您的集合数据。 第一次安装轮播时,我遇到了问题。 尝试两件事:

  1. 清洁并重建解决方案。 如果这没有帮助

  2. 卸载2之前的版本,安装1之前的版本。 检查它是否有效。 然后更新到pre-2。

我知道这很奇怪,但是那为我做了什么。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM