2016-11-15 61 views
0

我创建了一个CarouselPage但我需要轮播画面,所以我可以添加其他控制到页面上。出于某种原因,没有出现。不知道我错过了什么。轮播视图没有显示

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> 

这仅仅是一个测试代码试训转盘视图。

+0

你缺少结束标记ContentPage –

回答

1

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

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

  2. 卸载预2,安装前的1。检查它是否有效。然后更新到前2。

我知道这很奇怪,但那对我来说是什么。

+0

它现在,我必须将包添加到iOS和Android为好。 – LittleFunny

+0

清理重建为我工作。非常感谢你。 –