CarouselView not showing the data

大憨熊 提交于 2019-12-24 05:55:53

问题


I am trying to display a CarouselView inside a TabbedPage. I already added the (prerelease-)packages to the Project. Here is my xaml file:

            <control:CarouselView x:Name="CVMain"
                                  HeightRequest="150" >
                <control:CarouselView.ItemTemplate>
                    <DataTemplate>
                            <Label HorizontalOptions="Center"
                                   Text="Just a test :)"
                                   VerticalOptions="Center" />
                    </DataTemplate>
                </control:CarouselView.ItemTemplate>
            </control:CarouselView>

(control: xmlns:control="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView")

The label doesn't show up when I launch my app. The carousel still exists tho, I can confirm that by adding the BackgroundColor="Green"attribute to the CarouselView.

What am I missing?

Edit: As suggested, I placed the Label inside a Grid, but without any success (I also added an Image):

        <control:CarouselView x:Name="CVMain" HeightRequest="150">
            <control:CarouselView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Image Grid.RowSpan="2"
                               Aspect="AspectFill"
                               Source="{Binding ImageBase64,
                                                Converter={StaticResource Base64ToImageConverter}}" />
                        <StackLayout Grid.Row="1">
                            <Label Text="Test123" />
                        </StackLayout>
                    </Grid>
                </DataTemplate>
            </control:CarouselView.ItemTemplate>
        </control:CarouselView>

来源:https://stackoverflow.com/questions/39636537/carouselview-not-showing-the-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!