Skip to content

Instantly share code, notes, and snippets.

@almirvuk
Last active August 3, 2017 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save almirvuk/0c718bec3c7e833a9deb8593850078d6 to your computer and use it in GitHub Desktop.
Save almirvuk/0c718bec3c7e833a9deb8593850078d6 to your computer and use it in GitHub Desktop.
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