locked
Initialize CarouselView in UWP? RRS feed

  • Question

  • User390233 posted

    Hey,

    how can I initialize CarouselView in UWP? working fine on Android but in UWP the ItemSource is empty.

    CarouselView

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage
    ... >   
        <NavigationPage.TitleView>
          ....
        </NavigationPage.TitleView>
    
        <ContentPage.ToolbarItems>
           ....
        </ContentPage.ToolbarItems>
    
        <StackLayout Margin="10">
            <CarouselView>
                <CarouselView.ItemsSource>
                    <x:Array Type="{x:Type x:String}">
                        <x:String>Baboon</x:String>
                        <x:String>Capuchin Monkey</x:String>
                        <x:String>Blue Monkey</x:String>
                        <x:String>Squirrel Monkey</x:String>
                        <x:String>Golden Lion Tamarin</x:String>
                        <x:String>Howler Monkey</x:String>
                        <x:String>Japanese Macaque</x:String>
                        <x:String>Mandrill</x:String>
                        <x:String>Proboscis Monkey</x:String>
                        <x:String>Red-shanked Douc</x:String>
                        <x:String>Gray-shanked Douc</x:String>
                        <x:String>Golden Snub-nosed Monkey</x:String>
                        <x:String>Black Snub-nosed Monkey</x:String>
                        <x:String>Tonkin Snub-nosed Monkey</x:String>
                        <x:String>Thomas's Langur</x:String>
                        <x:String>Purple-faced Langur</x:String>
                        <x:String>Gelada</x:String>
                    </x:Array>
                </CarouselView.ItemsSource>
            </CarouselView>
        </StackLayout>
    </ContentPage>
    

    calling from another class

    await Navigation.PushAsync(new MyCarouselPage());

    App.xaml.cs

              ' Xamarin.Forms.Forms.SetFlags("CarouselView_Experimental");
                Xamarin.Forms.Forms.Init(e);'
    

    Mainactivity.cs

            ' global::Xamarin.Forms.Forms.SetFlags("CarouselView_Experimental");
             global::Xamarin.Forms.Forms.Init(this, savedInstanceState);'
    

    AppDelegate.cs

    ' global::Xamarin.Forms.Forms.SetFlags("CarouselView_Experimental");
         global::Xamarin.Forms.Forms.Init();' 
    

    UWP

    Best regards

    Friday, February 7, 2020 11:23 AM

Answers

  • User390233 posted

    Interesting this works

        <CarouselView ItemsSource="{Binding EmptyMonkeys}"
              EmptyView="No items to display." >
        </CarouselView>
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, February 7, 2020 2:31 PM