Populate Images from Database and Append to StackLayout in Xamarin Forms

JassimRahmaJassimRahma USMember ✭✭✭✭

Hi,

I have below StackLayout:

<StackLayout Orientation="Horizontal">
**    // HERE IMAGES NEEDS TO BE POPULATED FROM DATABASE
**</StackLayout>

In the StackLayout I want to populate Images from the web service:

var client = new HttpClient();
client.BaseAddress = new Uri("https://www.domain.com/ws/populate_categories.php?merchant=" + Convert.ToString(Application.Current.Properties["ZeeraMerchantNumber"]));
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync("https://www.domain.com/ws/populate_categories.php?merchant=" + Convert.ToString(Application.Current.Properties["MerchantNumber"]));

if (response.IsSuccessStatusCode)
{
    var data = await response.Content.ReadAsStringAsync();
    var result = JsonConvert.DeserializeObject<List<Categoryetails>>(data);
    ObservableCollection<Categoryetails> trends = new ObservableCollection<Categoryetails>(result);

    IsBusy = false;

**    // HERE LOAD IMAGES INTO THE ABOVE STACKLAYOUT.
   // IMAGES SOURCE WILL BE SOMETHING LIKE THIS:
   //  https://www.domain.com/images/{CATEGORY_GUID}/{IMAGE_GUID}.png
**}

Kindly help...

Thanks,
Jassim

Best Answer

Answers

Sign In or Register to comment.