这是我第一次尝试使用CarouselView,我被它深深地打动了。我的XAML定义如下
<?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有一个定义如下的集合。
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; }
}我的问题是旋转木马就是不出现。都是空的。有人能给我带路吗?
发布于 2017-08-20 17:58:00
最后让它工作,只是想分享它,以防其他人遇到同样的情况。
您还需要在您的Droid项目(或您正在使用的任何平台)中安装Nuget包。以前,我只在我的便携媒体库中安装。
https://stackoverflow.com/questions/45780641
复制相似问题