I am not getting that... although my code returns the data properly when debugging it
using System;
using System.Collections.Generic;
using System.Text;
using Syncfusion.ListView.XForms;
using Syncfusion.XForms.PopupLayout;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace MyApp
{
public class ViewModelAdLocation : INotifyPropertyChanged
{
public Command<object> TapCommand { get; set; }
SfPopupLayout popupLayout;
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string name)
{
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(name));
}
public int ad_location_id { get; set; }
public string country_name { get; set; }
public double? location_latitude { get; set; }
public double? location_longitude { get; set; }
public string location_address { get; set; }
public string telephone { get; set; }
public bool is_readonly { get; set; }
public ViewModelAdLocation()
{
TapCommand = new Command<object>(EditButtonTapped);
}
private void EditButtonTapped(object obj)
{
popupLayout = new SfPopupLayout();
popupLayout.PopupView.HeightRequest = 500;
popupLayout.PopupView.WidthRequest = 300;
// popupLayout.BindingContext = ModelBinding;
popupLayout.PopupView.ContentTemplate = new DataTemplate(() =>
{
var mainStack = new StackLayout();
mainStack.BackgroundColor = Color.AliceBlue;
var image = new Image();
image.SetBinding(Image.SourceProperty, new Binding("ContactImage"));
var grid = new Grid();
var NameLabel = new Label()
{
Text = "Customer Name "
};
NameLabel.HorizontalOptions = LayoutOptions.Start;
var label1 = new Entry()
{
};
label1.SetBinding(Entry.TextProperty, new Binding("ContactName"));
label1.HorizontalOptions = LayoutOptions.Start;
var NumberLabel = new Label()
{
Text = "HERE LOCATIO ID"
};
NumberLabel.HorizontalOptions = LayoutOptions.Start;
var label2 = new Entry()
{
};
label2.SetBinding(Entry.TextProperty, new Binding("ContactNumber"));
label2.HorizontalOptions = LayoutOptions.Start;
grid.Children.Add(NameLabel, 0, 0);
grid.Children.Add(label1, 1, 0);
grid.Children.Add(NumberLabel, 0, 1);
grid.Children.Add(label2, 1, 1);
mainStack.Children.Add(image);
mainStack.Children.Add(grid);
return mainStack;
});
popupLayout.PopupView.ShowHeader = false;
popupLayout.PopupView.ShowFooter = false;
popupLayout.HeightRequest = 500;
popupLayout.WidthRequest = 500;
popupLayout.Show();
}
}
}
protected override async void OnAppearing()
{
var client = new HttpClient();
client.BaseAddress = new Uri("https://www.domain.com/populate.php");
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("language", "EN"),
new KeyValuePair<string, string>("ad", ad_id)
});
var response = await client.PostAsync("https://www.domain.com/populate.php", content);
var data = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<List<ViewModelAdLocation>>(data);
ObservableCollection<object> trends = new ObservableCollection<object>();
for (int i = 0; i < result.Count; i++)
{
LocationData data1 = new LocationData()
{
ad_location_id = result[i].ad_location_id,
country_name = result[i].country_name,
location_address = result[i].location_address,
telephone = result[i].telephone
};
trends.Add(data1);
}
// await DisplayAlert("ID", Convert.ToString(ad_id), "OK");
ListViewNewAdLocations.ItemsSource = trends;
BusyIndicatorNewAdLocation.IsVisible = false;
ListViewNewAdLocations.IsVisible = true;
}