gpt4 book ai didi

xaml - Xamarin.Forms中的编译错误 “Can not set the content of ListView as it doesn' t具有ContentPropertyAttributte”

转载 作者:行者123 更新时间:2023-12-02 10:53:45 25 4
gpt4 key购买 nike

我基本上希望ListView单元具有自动高度,这就是我想到的:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MovieDbApp.UI"
x:Class="MovieDbApp.View.MoviesPage">
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListView x:Name="listView" Grid.Row="0">
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding Title}" />
<Image Source="{Binding PosterPath}" />
<Label Text="{Binding ReleaseDate}" />
<Label Text="{Binding DisplayGenre}" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView>
</Grid>
</ContentPage.Content>
</ContentPage>

这应该很简单,但是现在我遇到了编译错误,我也不知道它是什么意思,因为ListView中没有 ContentPropertyAttributte,或者至少找不到。

最佳答案

您缺少<ListView.ItemTemplate>

       <ListView x:Name="listView" Grid.Row="0">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding Title}" />
<Image Source="{Binding PosterPath}" />
<Label Text="{Binding ReleaseDate}" />
<Label Text="{Binding DisplayGenre}" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

关于xaml - Xamarin.Forms中的编译错误 “Can not set the content of ListView as it doesn' t具有ContentPropertyAttributte”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51860772/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com