Created
July 20, 2017 00:49
-
-
Save pictos/aa4580d66cd78d629c26397844987068 to your computer and use it in GitHub Desktop.
View Model principal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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