We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add or remove an item from Xamarin.Forms ListView (SfListView)

Platform: Xamarin.Forms |
Control: SfListView |
Published Date: March 24, 2020 |
Last Revised Date: March 24, 2020

You can add or remove items from ItemsSource with a bound collection from ViewModel in Xamarin.Forms SfListView.


ViewModel commands bound to view to add or remove item.

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
            <Grid HeightRequest="50" >
                <Button Text="Add item" Grid.Column="0" Command="{Binding AddCommand}"/>
                <Button Text="Delete last item" Grid.Column="1" Command="{Binding DeleteCommand}}"/>
            <syncfusion:SfListView x:Name="listView" 
                                   ItemsSource="{Binding contactsinfo}">
                <syncfusion:SfListView.ItemTemplate >
                        <Grid x:Name="grid" RowSpacing="0">
                            <Grid RowSpacing="0">
                                    <ColumnDefinition Width="70" />
                                    <ColumnDefinition Width="*" />
                                <Image Source="{Binding ContactImage}" VerticalOptions="Center" HorizontalOptions="Center" HeightRequest="50" WidthRequest="50"/>
                                <Grid Grid.Column="1" RowSpacing="1" Padding="10,0,0,0" VerticalOptions="Center">
                                    <Label LineBreakMode="NoWrap" TextColor="#474747" Text="{Binding ContactName}"/>
                                    <Label Grid.Row="1" Grid.Column="0" TextColor="#474747" LineBreakMode="NoWrap" Text="{Binding ContactNumber}"/>


Object added to the collection of ViewModel.

public class ContactsViewModel
  public Command AddCommand { get; set; }
    public ContactsViewModel ()
        AddCommand = new Command(OnAddTapped);
    private void OnAddTapped(object obj)
      var details = new Contacts()
          ContactNumber = random.Next(100, 400).ToString() + "-" + random.Next(500, 800).ToString() + "-" + random.Next(1000, 2000).ToString(),
          ContactName = CustomerNames[random.Next(1, 50)],
          ContactImage = ImageSource.FromResource("ListViewXamarin.Images.Image" + random.Next(0, 28) + ".png", typeof(MainPage)),


Object removed from the collection of ViewModel.

public class ContactsViewModel
  public Command DeleteCommand { get; set; }
    public ContactsViewModel ()
        DeleteCommand = new Command(OnDeleteTapped);
    private void OnDeleteTapped(object obj)
      if (contactsinfo.Count > 0)
          contactsinfo.Remove(contactsinfo[contactsinfo.Count - 1]);
          App.Current.MainPage.DisplayAlert("Alert", "There is no item in the list", "OK");


View sample in GitHub

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile