Last active
August 3, 2017 17:39
-
-
Save almirvuk/0c718bec3c7e833a9deb8593850078d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CarsExample.Models; | |
using CarsExample.Utils; | |
using System; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.ComponentModel; | |
using System.Linq; | |
using System.Runtime.CompilerServices; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace CarsExample.ViewModels { | |
public class CarsViewModel : INotifyPropertyChanged { | |
private ObservableCollection<Car> items; | |
public ObservableCollection<Car> Items { | |
get { return items; } | |
set { | |
items = value; | |
} | |
} | |
public CarsViewModel() { | |
// Here you can have your data form db or something else, | |
// some data that you already have to put in the list | |
Items = new ObservableCollection<Car>() { | |
new Car() | |
{ | |
CarID = 1, | |
Make = "Tesla Model S", | |
YearOfModel = 2015 | |
}, | |
new Car() | |
{ | |
CarID = 2, | |
Make = "Audi R8", | |
YearOfModel = 2012 | |
}, | |
}; | |
// Web service call to update list with new values | |
MyHTTP.GetAllNewsAsync(list => | |
{ | |
foreach (Car item in list) | |
Items.Add(item); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment