0

I'm trying CarouselView on my project. But when I Run my project,I get this error.

Here is my xaml code;

<?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>

And here is I called json service;

 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);
                        }
                    }

i is Hotel index number of for and j is Hotels' image index number

2
  • Looks like you have an exception. :-) Please post the code that is failing and a full stack trace. Avoid posting text as a photo. Commented Aug 8, 2016 at 13:35
  • I have added more detail... Look at this please. Commented Aug 10, 2016 at 15:50

1 Answer 1

1

In the forum of Xamarin report this error like a bug is the same error. 21 of June

https://forums.xamarin.com/discussion/69483/why-does-carouselview-crash-on-android

what version of Xamarin you have installed? you try to install the latest version of xamarin?

Sign up to request clarification or add additional context in comments.

7 Comments

I have added more details.
I update the answer let me know if you solve the problem. Regards
Unfortunately, already I've seen this report but it's not like my error. I'm using Xamarin 4.1.1.
Try to update your version. You say that is not your error is exactly your error. @ozmert75 Exception: System.MethodAccessException: Method Xamarin.Forms.BindingBase:TryGetSynchronizedCollection (System.Collections.IEnumerable,Xamarin.Forms.CollectionSynchronizationContext&)' is inaccessible from method Xamarin.Forms.ItemsView/ItemsSourceProxy:get_SyncContext ()'
I'm trying it,I will share the results with you, thanks.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.