Skip to content

Instantly share code, notes, and snippets.

@rid00z
Last active August 29, 2015 14:02
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 rid00z/7266fd6c98d7a25b4b41 to your computer and use it in GitHub Desktop.
Save rid00z/7266fd6c98d7a25b4b41 to your computer and use it in GitHub Desktop.
A sample PageModel from a Xamain.Forms Mvvm
public class QuotePageModel : BasePageModel
{
IDatabaseService _databaseService;
public Quote Quote { get; set; }
//The database service is automatically injected.
public QuotePageModel (IDatabaseService databaseService)
{
_databaseService = databaseService;
}
//This is executed when the model is pushed
public void Init(object data)
{
Quote = data as Quote;
if (Quote == null)
Quote = new Quote ();
}
public Command Done
{
get {
return new Command (() => {
//This pops the current Page
PopPageModel();
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment