好吧,所以我有這個listview應該顯示一堆項目,其中每個項目至少包含一張照片。從URI加載在列表視圖中的圖像xamarin形式
這個想法是顯示listCell中的主要照片,並且當一個項目被選中時,其細節被顯示在不同的表格頁面中,並且在那裏它應該能夠訪問它的所有照片。
當該項目沒有照片時,它將顯示一個來自資源的佔位符。
問題:無法從URI加載圖像,要麼將圖像源綁定到包含特定URI obj的list屬性(來自viewModel),要麼將它綁定到包含現在字符串的相同屬性,或者通過手段的
<Image.Source>
<UriImageSource Uri="{Binding MainPhotoSource}" />
</Image.Source>
不管。這些似乎都不起作用。
已經向Xamarin團隊尋求幫助,他們的答案是來到這裏,或者去論壇(我已經做了,現在已經等了近兩個月,而且需要交付工作)..
請幫忙嗎?
編輯: 這是一段ViewModel代碼。
在第一種方法中,對於從WCF接收到的每個項目,我將此ItemDto obj格式的等效項添加到此ObservableCollection列表中。
// Sets this List observable collection to a new ItemDto obj,
// with certain properties from the Item.Find result[].
ObservableCollection<ItemDto> SetList(Item.Find[] result)
{
ObservableCollection<ItemDto> collection = new ObservableCollection<ItemDto>();
foreach (Item.Find item in result)
{
collection.Add(GetDto(item));
}
return collection;
}
// Gets a new ItemDto obj with the required fields from Item.Find obj.
ItemDto GetDto(Item.Find item)
{
return new ItemDto()
{
ID = item.ID,
UserID = item.User_ID,
MainPhotoSource = new Uri(_serverInbox + item.MediaItems[0].RelativeUrl),
Title = item.Title,
Description = item.Description,
Category = item.Category_Name,
DateCreated = GetFormatedDateCreated(item.DateCreated)
};
}
也添加您的viewmodel代碼。因爲這似乎是罰款 – Sreeraj