I have a simple data entry page called NewCustomerPage
that's bound to a viewmodel called NewCustomerViewModel
like so:
public partial class NewCustomerPage : ContentPage { public NewCustomerViewModel _newCustomerViewModel; public NewCustomerPage() { InitializeComponent(); _newCustomerViewModel = new NewCustomerViewModel(); this.BindingContext = _newCustomerViewModel; } }
Inside the page there's a series of text fields bound to an object property Customer
in the viewmodel. What I need to do is save said object in a database and this is where I'm having issues. If Customer
was inside of the page I could simply put the code inside of the event raised when clicking a button on the UI and be done with it. With the object residing in the viewmodel, though, I need a way to invoke said code from the UI.
From my readings I suspect I need to use one of the two between a Command or the Messaging Center. Am I right? Is this the best approach to my necessities?