Kasım Çakar
Kasım Çakar

Reputation: 1

System.TypeInitializationException Xamarin CarouselView

The type initializer for 'Xamarin.Forms.ItemsView' threw an exception. After click button.

Unhandled Exception:

System.TypeInitializationException: The type initializer for 'Xamarin.Forms.ItemsView' threw an exception. occurred

`<CarouselView>
                    <CarouselView.ItemsSource>
                        <x:Array Type="{x:Type View}">
                            <ContentView>
                                <Image Source="yuzon.jpg"/>
                            </ContentView>
                            <ContentView>
                                <Image Source="yuzyirmi.jpg"/>
                            </ContentView>
                            <ContentView>
                                <Image Source="yuzkirks.jpg" />
                            </ContentView>
                            <Image Source="yuzelli.jpg" />
                            <ContentView>
                                <Image Source="yuzaltmis.jpg" />
                            </ContentView>
                            <ContentView>
                                <Image Source="ikiyuzyirmi.jpg"/>
                            </ContentView>
                            <ContentView>
                                <Image Source="ikiyuzkirkC.jpg" />
                            </ContentView>
                            <ContentView>
                                <Image Source="ikiyuzyetmis.jpg" />
                            </ContentView>
                            <Image Source="ucyuz.jpg"  />
                            <ContentView>
                                <Image Source="ucyuzF.jpg"  />
                            </ContentView>
                            <ContentView>
                                <Image Source="ucyuzon.jpg" />
                            </ContentView>
                            <ContentView>
                                <Image Source="ucyuzotuz.jpg"  />
                            </ContentView>
                            <ContentView>
                                <Image Source="ucyuzaltmis.jpg"  />
                            </ContentView>
                        </x:Array>
                    </CarouselView.ItemsSource>
                </CarouselView>` 

Upvotes: 0

Views: 862

Answers (1)

Ax1le
Ax1le

Reputation: 6641

This control belongs to Xamarin.Forms 4.0. So you have to update your forms version to 4.0 to test this new feature.

Moreover, you have to add
global::Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental"); in your MainActivity.cs and AppDelegate to enable this testing.

Unfortunately, Carousel View can be only used on Android: https://github.com/pauldipietro/CollectionViewSample.

Follow this blog to learn more concepts: https://devblogs.microsoft.com/xamarin/xamarin-forms-4-0-feature-preview-an-entirely-new-point-of-collectionview/

Upvotes: 2

Related Questions