Forum Xamarin Xamarin.Forms

How to paint an image and a label with a database record?

ABloxityABloxity Member ✭✭✭

I have a record in a table

and I want to paint the I like that I bring from that register with the idmegusta

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Do you use ListView or CollectionView to present these data?
    Try to define a model class to access the table from the database. Maybe like:

    public class Model
    {
        public string idmegusta { set; get; }
        // ...
    }
    

    Then deserialize the records to a list of model. Binding the label's text to these properties will make it work.

  • ABloxityABloxity Member ✭✭✭

    @LandLu
    If so I have my data model.
    I am occupying an ObservableCollection.

  • ABloxityABloxity Member ✭✭✭

    @LandLu
    Get the id, and I want to buy it so that the image of like and the text turns blue

  • LandLuLandLu Member, Xamarin Team Xamurai

    What do you mean about "so that the image of like and the text turns blue".
    You want to change the text color when the user selected the item or these images couldn't be rendered correctly as you expected?

  • ABloxityABloxity Member ✭✭✭

    @LandLu
    Yes, I want to load my list of publications, with the record I have of the likes with a publication the blue icon and the text in blue are loaded

  • LandLuLandLu Member, Xamarin Team Xamurai

    It seems you could load text and images successfully from the database. What's your question now?

  • ABloxityABloxity Member ✭✭✭

    @LandLu
    how to do it, I bring the idmegusta record, to compare it and thus automatically paint the image and text

  • LandLuLandLu Member, Xamarin Team Xamurai

    I saw you had a Publicaciones model to access the records from the database. Then we could retrieve a list of this model for display. Bind your list's items source to this list then each item could use binding to display the information. Which part are you confused about?
    If you want to know more about the construct of listview this documentation could be helpful:
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/listview/

Sign In or Register to comment.