CarouselView.Content is empty

I try study is new componet CarouselView and с# in total. But I have problem. This code display is empty content in CarouselView. Why? I send is fill code my colutions.

<?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:carousel="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"   
             xmlns:local="clr-namespace:App6"
             x:Class="App6.MainPage">
    <StackLayout>
        <Image Source="home.png"/>
        <carousel:CarouselViewControl x:Name="MyCV" BackgroundColor="Black">
            <carousel:CarouselViewControl.ItemTemplate>
                <DataTemplate>
                    <StackLayout>
                        <Label Text="{Binding TestLine}"></Label>
                    </StackLayout>
                </DataTemplate>
            </carousel:CarouselViewControl.ItemTemplate>
        </carousel:CarouselViewControl>         
    </StackLayout>
</ContentPage>


namespace App6
{
    public partial class MainPage : ContentPage
    {
        class CustomCell
        {
            public string TestLine { get; set; }
        }

        public MainPage()
        {      
            InitializeComponent();

            List<CustomCell> myCarousel = new List<CustomCell>();
            myCarousel.Add(new CustomCell { TestLine = "Line 1" });
            myCarousel.Add(new CustomCell { TestLine = "Line 2" });
            MyCV.ItemsSource = myCarousel;
        }
    }
}

Upvotes: 1

Views: 165

Answers (1)

Ivan I
Ivan I

Reputation: 9990

Your code is correct, so your problem is in the visual layer. Try to define the height and width wherever possible and it should resolve the problem. CarouselView isn't the official control and isn't up to standards of Xamarin's built-in controls so it has some somewhat unexpected behaviors like this.

Upvotes: 1

Related Questions