Jassim Al Rahma
Jassim Al Rahma

Reputation: 15

Dynamic Xamarin Image Source Binding

I have the same question please..

I have the url this way:

mydomain.com/gallery/COMPANY_GUID/items/ITEM_GUID/600x400.png

where COMPANY_GUID and ITEM_GUID comes from the database here:

public class ItemDetails
{
    public int item_id { get; set; }
    public int item_guid { get; set; }
    public int merchant_guid { get; set; }
    public string item_name { get; set; }
    public string item_description { get; set; }
    public string item_price { get; set; }
}

How can I set the Images source {Binding item_image} where the item_image should be a dynamic variable comes from the above?

Upvotes: 0

Views: 335

Answers (1)

MilanG
MilanG

Reputation: 2604

public class ItemDetails
{
    public int item_id { get; set; }
    public int item_guid { get; set; }
    public int merchant_guid { get; set; }
    public string item_name { get; set; }
    public string item_description { get; set; }
    public string item_price { get; set; }
    //Add this field like this.
    public string item_image {
        get {
                return string.Format("mydomain.com/gallery/{0}/items/{1}/600x400.png", merchant_guid, item_guid);
            }
        }
    }

Try to add one field item_image as given in the above code. This will return what you need, dynamically. Hope this will help you.

Upvotes: 1

Related Questions