Reputation: 3410
I have been playing with Xamarin for a short time so far, and i just stumbled into something i couldn't find the answer into their documentation.
I am building a fairly simple app that retrieves "User Data" (username, email, password and so forth) from a RESTfull API and populates a listview with some of the data (This is the point i am at the moment. It works).
The next step is to build a "Edit User" screen, which is invoked uppon selecting (tapping) a user on the Listview i currently have.
I have managed to build a simple view that is basically two Entry Cells showing the data of the user picked into the previous listview screen. That also works.
The problem is that, once i edit the data into the "Entry Cell" it has no reflection into the "User Model" that populated the "entry cell" in first place.
How do i bind those together?
Code Sample:
// Entry Cell of Username (Should be Binded)
EntryCell ecUsername = new EntryCell()
{
Label = "Username:",
Placeholder = "username / login",
Text = _user.Username
};
// Entry Cell of Password (Should be Binded)
EntryCell ecEmail = new EntryCell ()
{
Label = "Email:",
Placeholder = "user email",
Text = _user.Email
};
Some Screenshots:
Once i click into a user, its data gets rendered into the next screen.
Upvotes: 2
Views: 1544
Reputation: 89082
I haven't tested this, but something like this should work:
EntryCell ec = new EntryCell ();
ec.BindingContext = _user;
ec.SetBinding (EntryCell.TextProperty, "Username");
Upvotes: 2