Kак решить вопрос,использую "SearchBar" и "JSON" в Xamarin,получить данную ошибку
Данная ошибка
System.ArgumentNullException: 'Value cannot be null.
Parameter name: source'
GetJSON
private async void GetJSON()
{
//Check network status
if (NetworkCheck.IsInternet())
{
var client = new System.Net.Http.HttpClient();
var response = await client.GetAsync("");
string contactsJson = await response.Content.ReadAsStringAsync();
//Converting JSON Array Objects into generic list
var ObjContactList = (Contact[])JsonConvert.DeserializeObject<Contact[]>(contactsJson);
var descListOb = ObjContactList.OrderByDescending(x => x.Recovered);
listviewConacts.ItemsSource = descListOb;
}
else
{
await DisplayAlert("JSONParsing", "No network is available.", "sex");
}
//Hide loader after server response
ProgressLoader.IsVisible = false;
}
CountrySearchBar_TextChanged
public List<Contact> Items { get; set; }
private void CountrySearchBar_TextChanged(object sender, TextChangedEventArgs e)
{
var keyword = CountrySearchBar.Text;
IEnumerable<Contact> sugggestions = Items.Where(c =>
c.CombinedKey.ToLower().Contains(keyword.ToLower()));
listviewConacts.ItemsSource = sugggestions;
}
JsonModel
public class Contact
{
[JsonProperty("provinceState")]
public string ProvinceState { get; set; }
[JsonProperty("countryRegion")]
public string CountryRegion { get; set; }
}
}