Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jfversluis
Last active March 30, 2020 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfversluis/12d166a400f18688e523430258d70a15 to your computer and use it in GitHub Desktop.
Save jfversluis/12d166a400f18688e523430258d70a15 to your computer and use it in GitHub Desktop.
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