我在我的项目上尝试CarouselView。但是当我运行我的项目时,我收到了这个错误。
这是我的xaml代码;
<?xml version="1.0" encoding="UTF-8"?>
<base:HotelDetailPageXaml
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamarinCRM.Pages.Hotels.HotelDetailPage"
xmlns:statics="clr-namespace:XamarinCRM.Statics"
xmlns:base="clr-namespace:XamarinCRM.Pages.Hotels"
xmlns:hotelViews="clr-namespace:XamarinCRM.Views.Hotels"
xmlns:i18n="clr-namespace:XamarinCRM.Localization"
xmlns:cv="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView"
Title="{Binding Hotel.Name}">
<base:HotelDetailPageXaml.Content>
<StackLayout Spacing="0">
<cv:CarouselView ItemsSource="{Binding Hotel.HotelImages}">
<cv:CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout HeightRequest="200">
<Image HeightRequest="200" Aspect="AspectFill" Source="{Binding FullPath}"/>
</StackLayout>
</DataTemplate>
</cv:CarouselView.ItemTemplate>
</cv:CarouselView>
</StackLayout>
</base:HotelDetailPageXaml.Content>
</base:HotelDetailPageXaml>
这是我叫json服务;
public async Task<IEnumerable<HotelModel>> GetHotelsAsync(bool includeLeads = false)
{
string path = "my service url";
HttpClient Client = new HttpClient();
var task = await Client.GetAsync(path);
var jsonString = await task.Content.ReadAsStringAsync();
List<HotelModel> hotelList = new List<HotelModel>();
List<HotelImageModel> hotelImageList = new List<HotelImageModel>();
dynamic json = JsonConvert.DeserializeObject(jsonString);
for (int j = 0; j < 10; j++)
{
HotelImageModel hotelImage = new HotelImageModel();
hotelImage.FullPath = json["data"][i]["HotelImages"][j]["FullPath"].Value;
hotel.HotelImages.Add(hotelImage);
}
}
我是酒店的索引号,而j是酒店的图像索引号
答案 0 :(得分:1)
在Xamarin的论坛中报告此错误就像一个错误是同样的错误。 6月21日
https://forums.xamarin.com/discussion/69483/why-does-carouselview-crash-on-android
您安装了哪个版本的Xamarin?您是否尝试安装最新版本的xamarin?