How do i bind an "Entry Cell" to a custom object using Xamarin?

Marcello Grechi Lins

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: ListView of Users

Once i click into a user, its data gets rendered into the next screen.

Edit Screen

Jason

I haven't tested this, but something like this should work:

EntryCell ec = new EntryCell ();
ec.BindingContext = _user;
ec.SetBinding (EntryCell.TextProperty, "Username");

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I load a custom Font in Xamarin using UrhoSharp?

How do I bind a Label to a property in Xamarin?

How to set a background image to an entry cell in xamarin.forms

How to set left and right padding to an entry cell in xamarin.forms

How do I bind data from MySQL database to Xamarin ListView?

How do I bind a multi level configuration object using IConfiguration in a .net Core application?

How do I bind an object that is periodically modified to a treeview in C# WPF using the CommunityToolkit.MVVM?

How to bind custom object to spinner layout using databinding library?

How do I add a Custom Overlay for ZXingScannerView in Xamarin Forms using the MVVM pattern?

How do I bind two instances of an object in WPF (Or can I?)

How do I fill an object with a custom image in Javascript using Canvas on a moving object?

How do I bind to a custom event in an angularjs directive?

How do I bind a custom property to a textfield bidirectionally?

How do I bind data to an html object conditioned on whether the html dataset and object key values are matching using javascript?

How do I bind a MVC 5 list to a JSON object

How do I bind the properties of an object to a WPF control?

How do I bind to an object in my model to a user control in WPF?

How do I bind an object to a dynamically created label?

How do I use a custom font in Xamarin.Android?

How do I make my Custom Control float in Xamarin Forms?

How do I add a custom view on click of a button Xamarin

How can I bind a function to an object instance using decorator?

How do I bind the same data to different options using angulajs?

How do I execute a SQL script using a bind variable

How do I bind Different Interfaces using Google Guice?

How Do I Bind Different Concretes to a Property Using StructureMap

How do I bind this 1 variable using mysqli?

How do I correctly bind keys using the command pattern?

How do I bind a css class to a button in vue using or?