动态Xamarin图像源绑定
问题描述:
我有同样的疑问,请..动态Xamarin图像源绑定
我的网址是这样的:
mydomain.com/gallery/COMPANY_GUID/items/ITEM_GUID/600x400.png
其中COMPANY_GUID和ITEM_GUID来自数据库的位置:
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; }
}
我如何可以设置图片来源{Binding item_image}其中item_image应该是一个动态变量来自上面?
答
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);
}
}
}
尝试添加上面代码中给出的一个字段item_image
。这将动态地返回你所需要的。希望这会帮助你。
或者干脆写一个转换器 – Kowalski
解决了我的问题。谢谢.. –
很高兴看到它帮助! – MilanG