Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Populating List View from observable collection

$
0
0

I have a static observable collection in my view model that I have populated from a web service response.

This is the data from the response
"Routes": [
{
"Id": 1,
"Date": "2015-03-04T00:00:00",
"Area": "2887",
"Detail": "",
"Driver": "",
"SampleType": "",
"Schedule": "A",
"Tag": "",
"Vehicles": [
{
"VehicleId": 2,
"VehicleRego": "BZS162",
"Primary": true,
"Compartments": [
{
"Id": "1",
"Capacity": 10000.0,
"Product": ""
},
{
"Id": "2",
"Capacity": 10000.0,
"Product": ""
},
{
"Id": "3",
"Capacity": 5000.0,
"Product": ""
}
]
},
{
"VehicleId": 583,
"VehicleRego": "BRJ722",
"Primary": false,
"Compartments": [
{
"Id": "1",
"Capacity": 16000.0,
"Product": ""
}
]
}
],
"Pickups": [
{
"Quantity": 4700.0,
"Id": 1,
"Vat": 0,
"Hazards": "",
"Latitude": "-35.45944000000",
"Longitude": "-60.76161000000",
"Message": "",
"Supplier": {
"Id": 2223,
"Name": "INCHAURRONDO M.J.B.Y GIANOTTI SH"
},
"Product": "Milk",
"ProductKey": "2",
"Ticket": "",
"EstmatedPickup": "2015-03-04T20:00:00+13:00"
},
{
"Quantity": 5300.0,
"Id": 1,
"Vat": 0,
"Hazards": "",
"Latitude": "-35.30333000000",
"Longitude": "-61.33347000000",
"Message": "",
"Supplier": {
"Id": 2158,
"Name": "FENIX SOCIEDAD CIVIL"
},
"Product": "Milk",
"ProductKey": "2",
"Ticket": "",
"EstmatedPickup": "2015-03-04T20:53:23+13:00"
},
{
"Quantity": 5800.0,
"Id": 1,
"Vat": 0,
"Hazards": "",
"Latitude": "-35.29028000000",
"Longitude": "-61.31453000000",
"Message": "",
"Supplier": {
"Id": 3125,
"Name": "TECNOVA S.A.PLANIF.NVA TECNOLOGIA"
},
"Product": "Milk",
"ProductKey": "2",
"Ticket": "",
"EstmatedPickup": "2015-03-04T20:55:20+13:00"
},
{
"Quantity": 4800.0,
"Id": 1,
"Vat": 0,
"Hazards": "",
"Latitude": "-34.62611000000",
"Longitude": "-62.00733000000",
"Message": "",
"Supplier": {
"Id": 661,
"Name": "EL HUAQUEN S.A.AGROPECUARIA"
},
"Product": "Milk",
"ProductKey": "2",
"Ticket": "",
"EstmatedPickup": "2015-03-04T22:04:02+13:00"
}
],
"Downloaded": true,
"Completed": false
},

View model contains
public static ObservableCollection route { get; set; }

The observable collection is being populated. I can iterate through the collection and get the route Id for example like this
foreach (var route in ViewModelBase.route)
{
var theRoute = route.Id
}

However I am getting a blank screen when trying to populate the list view. Here's part of the Xaml

<ListView x:Name="routeListView" ItemsSource="{Binding route}">
  <ListView.ItemTemplate>
    <DataTemplate>
      <TextCell Text="{Binding Id}" />
    </DataTemplate>
  </ListView.ItemTemplate>
</ListView>

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>