Click here to Skip to main content
14,602,100 members
Rate this:
Please Sign up or sign in to vote.
{"$id":"1","Version":"1.0.0","dateTime":"2020/07/31 09:03:05","StatusCode":1,"ErrorMessage":"Success","Result":{"$id":"2","getpartnumberover":[{"$id":"3","partnumber":"14312-054-1","productname":"fill-line-hose-assy"}]}}

Please see the above json

Xaml Code

<ListView x:Name="MyListView" ItemsSource="{Binding MyListView}">

                       <StackLayout Orientation="Horizontal" Margin="5" HeightRequest="90">

                           <Label Text="{Binding partnumber}" TextColor="Black"></Label>



Data is not getting bind and c# code is working fine but the mobile app is showing the blank page

What I have tried:

using (var httpClient = new HttpClient())
                httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "application/json");
                httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0");

                var response = httpClient.GetAsync("APi url").Result;
                string stud = response.Content.ReadAsStringAsync().Result;
                JToken m = JToken.Parse(stud);
                JArray men = (JArray)m.SelectToken("Result.over");
                foreach (var zaq in men)
                    MyListView.ItemsSource = zaq.SelectToken("partnumber").ToString();
Updated 31-Jul-20 6:15am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

.ItemsSource takes a "list" (i.e. collection), not a (single) "string".

ListView Data Sources - Xamarin | Microsoft Docs[^]
sonutool 5 days ago
I have tried this its not working @gerry

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100