Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
View model for our main page
using System.Collections.ObjectModel;
using Xamarin.Forms;
namespace DataBindingScopeSample
{
public class ListModel
{
public string Title { get; set; }
public string Image { get; set; }
}
public class MainPageViewModel
{
public ObservableCollection<ListModel> MyItems { get; set; } = new ObservableCollection<ListModel>
{
// List filling here
};
public Command<ListModel> DeleteCommand { get; private set; }
public MainPageViewModel()
{
DeleteCommand = new Command<ListModel>(model =>
{
MyItems.Remove(model);
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment