Skip to content

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

Notifications You must be signed in to change notification settings

SyncfusionExamples/xamarin.forms-listview-selecteditems-binding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

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

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6

Languages