private void TourRequestFinished(HttpResponse response) { if (response.Successful) { // process response outside UI thread Deployment.Current.Dispatcher.BeginInvoke(() => { // set your data to view model or control (this code is called in the UI thread) var jsonResponse = response.Response; JObject jsonObject = JObject.Parse(jsonResponse); JArray entries = (JArray)jsonObject["concerts"]; for (int i = 0; i < entries.Count; i++) { ConcertItemViewModel concertItem = new ConcertItemViewModel(); concertItem.Title = entries[i]["title"].ToString(); concertItem.Date = entries[i]["subtitle"].ToString(); concertItem.Latitude = entries[i]["latitude"].ToString(); concertItem.Longitude = entries[i]["longitude"].ToString(); this.Concerts.Add(concertItem); } tourBusy = false; updateBusy(); }); } else { if (!response.Canceled) { tourBusy = false; updateBusy(); // display exception MessageBox.Show("Error loading tour - Try again"); } } }
public Map() { InitializeComponent(); concert = new ConcertItemViewModel(); }