Skip to content

Instantly share code, notes, and snippets.

@asimmon
Created November 20, 2015 15:55
Show Gist options
  • Save asimmon/dca757f49da463b831f9 to your computer and use it in GitHub Desktop.
Save asimmon/dca757f49da463b831f9 to your computer and use it in GitHub Desktop.
EventToCommand Xamarin Forms - Example ViewModel
public class HomeViewModel : ViewModelBase
{
public ObservableCollection<PersonViewModel> People { get; set; }
public RelayCommand<PersonViewModel> SayHelloCommand { get; set; }
public HomeViewModel()
{
People = new ObservableCollection<PersonViewModel>
{
new PersonViewModel("John"),
new PersonViewModel("Mike"),
new PersonViewModel("Jane")
};
SayHelloCommand = new RelayCommand<PersonViewModel>(SayHello);
}
public void SayHello(PersonViewModel person)
{
Debug.WriteLine("Hello {0}!", person.Name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment