So here is my Model class
public class User{ public String Name; public String Email; }
So here is my XAML
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SampleApp.Screens.AdminApproveUsers" Title="Approve Users"> <ScrollView> <ListView x:Name="lstUsers"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.View> <StackLayout Orientation="Horizontal" VerticalOptions="Center" HorizontalOptions="Center"> <Label Text="{Binding Name}" TextColor="Black" /> <Label Text="{Binding Email}" TextColor="Black" /> </StackLayout> </ViewCell.View> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </ScrollView> </ContentPage>
And this is how I bind it
public async void Initialize() { try { List<User> users = await ApiHandler.UserHandler.GetUsers(); this.BindingContext = users; lstUsers.ItemsSource = users; lstUsers.ItemTapped += LstUsers_ItemTapped; } catch (Exception ex) { await DisplayAlert("Error", "Error Occurred", "OK"); } }
What am I doing wrong?
I think you must use ObservableCollection and INotifyPropertyChanged...
Answers
I think you must use ObservableCollection and INotifyPropertyChanged...
Wow you are amazing now it works. Pretty Cool. Thanks
hahaha, amazing
Take a look there
https://channel9.msdn.com/Shows/XamarinShow/Introduction-to-MVVM