Xamarin.Android MVVM Light ListView bindings
This is an extension databinding under Xamarin.Android which I describe more in detail in this post. In this post we will look at how to bind a collection to a Android ListView and update the View every time an item is added or removed from the collection in the View Model.
Project Setup
Add the MVVM Light libraries from Laurent Bugnion via NuGet to a Xamarin.Android project:
PM> Install-Package MvvmLight
Then in the View Model create an ObservableCollection which will represent the entire List.
public ObservableCollection<Person> People { get; private set; }
To setup the list we can use an Initializer method, which is currently generated in a separate thread. Now this only makes sense when the list is large i.e. processor heavy which this creation can be if we start jacking up the number. So with the basics all set lets turn our attention to the Activity.