Skip to content

Instantly share code, notes, and snippets.

@pictos
Created July 20, 2017 00:49
Show Gist options
  • Save pictos/aa4580d66cd78d629c26397844987068 to your computer and use it in GitHub Desktop.
Save pictos/aa4580d66cd78d629c26397844987068 to your computer and use it in GitHub Desktop.
View Model principal
using DeleteList.Model;
using System.Collections.ObjectModel;
using Xamarin.Forms;
namespace DeleteList.ViewModel
{
public class MainViewModel : BaseViewModel
{
public Command DeletarCommand { get; }
public ObservableCollection<Lista> Lista { get; }
public Lista ItemSelecionado { get; set; }
public MainViewModel()
{
Lista = new ObservableCollection<Lista>
{
new Lista("Pedro", "23"),
new Lista("Clara", "24"),
new Lista("Gustavo", "25"),
new Lista("Luciano", "26")
};
DeletarCommand = new Command(ExecuteDeletarCommand);
}
void ExecuteDeletarCommand()
{
if(ItemSelecionado != null)
{
Lista.Remove(ItemSelecionado);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment