Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Unable to Bind Objects in ListView Xamarin Forms

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=""
             Title="Approve Users">

    <ListView x:Name="lstUsers">
              <StackLayout Orientation="Horizontal" VerticalOptions="Center" HorizontalOptions="Center">
                <Label Text="{Binding Name}" TextColor="Black" />
                <Label Text="{Binding Email}" TextColor="Black"  />

And this is how I bind it

public async void Initialize()
                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?

Best Answer


Sign In or Register to comment.