Reputation: 13
I have a Person object with properties of Person{ string name; int number}; I built a form to send data to a Persons=list :
<Label Text="Name:"/>
<Entry x:Name="labelName" Text="{Binding Person.Name}" Placeholder="Name"/>
<Label Text="Nif:"/>
<Entry x:Name="labelNumber" Text="{Binding Person.Number}" Placeholder="Number"/>
<Button Text="Add" Command="{Binding AddCommand}"/>
then I wanted to show this data below in a collectionview but an error does not appear:
<CollectionView ItemsSource="{Binding Persons}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Name}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Error " The Name "Name" don't exist in the current context"
I don't understand why it gives me the error I did everything correctly and by binding
After choosing ItemSsource={Binding Persons} it would be possible that the elements chosen below would be from Person element, that is, it should work <Label Text={Binding Name} but not working.
Upvotes: 0
Views: 158