首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >旋转木马视图未显示

旋转木马视图未显示
EN

Stack Overflow用户
提问于 2016-11-15 10:05:32
回答 1查看 2.7K关注 0票数 0

我创建了一个CarouselPage,但是我需要CarouselView,所以我可以将其他控件添加到页面中。出于某种原因什么也没出现。不知道我错过了什么。

代码语言:javascript
复制
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部分:

代码语言:javascript
复制
<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>

这只是一个试用旋转木马视图的测试代码。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-16 19:32:59

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

  1. 清理和重建解决方案。如果这没有帮助的话
  2. 卸载预-2,安装预-1.检查它是否有效。然后更新到预-2。

我知道这很奇怪,但这是为我做的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40607007

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档