I have a simple view model:
public List<DisplayModel> Items { get; set; } = new List<DisplayModel>();
public class DisplayModel
{
public string Name { get; set; }
public string Prop { get; set; }
}
In my view, I have this collection view:
<CollectionView ItemsSource="{Binding Items}" >
<CollectionView.ItemTemplate>
<DataTemplate>
<VerticalStackLayout>
<Grid ColumnSpacing="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label TextColor="White" FontSize="18" FontFamily="WuerthExtraBold" Text="{Binding Name}"/>
<Label TextColor="White" FontSize="18" FontAttributes="Bold" Grid.Column="1" HorizontalTextAlignment="End" HorizontalOptions="End" Text="{Binding Prop}"/>
</Grid>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
but as soon as I hit compile, it tell me that the property name or prop arent found:
I can bind to that list, but just not with those properties. What is going on?
you need to add a DataType
<DataTemplate x:DataType="local:DisplayModel">