Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Binding SelectedItems in Listview

ListView support to select multiple items through binding the SelectedItems property from view model with ObservableCollection type. Set the SelectionMode property as Multiple.

<syncfusion:SfListView x:Name="listView" 
                       SelectedItems="{Binding SelectedItems}"
                       ItemsSource="{Binding BookInfoCollection}"/>
//ViewModel.cs

public class BookInfoRepository : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    private ObservableCollection<object> selectedItems;

    public ObservableCollection<object> SelectedItems
    {
        get { return this.selectedItems; }
        set
        {
            this.selectedItems = value;
            this.OnPropertyChanged("SelectedItems");
        }
    }

    public void OnPropertyChanged(string name)
    {
        if (this.PropertyChanged != null)
            this.PropertyChanged(this, new PropertyChangedEventArgs(name));
    }

    public BookInfoRepository()
    {
        SelectedItems = new ObservableCollection<object>();
        SelectedItems.Add(BookInfoCollection[1]);
        SelectedItems.Add(BookInfoCollection[2]);
    }
}

To know more about MVVM in ListView, please refer our documentation here

About

This repository contains the sample which shows binding of SelectedItems using MVVM in Xamarin.Forms ListView?

Topics

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages