private SortableBindingList <Album> GetAlbums() { var list = new SortableBindingList <Album>(); using (StreamReader file = File.OpenText(jsonPath)) using (JsonTextReader reader = new JsonTextReader(file)) { JObject jObject = (JObject)JToken.ReadFrom(reader); foreach (var obj in jObject) { list.Add(new Album() { albumId = obj.Key, artist = obj.Value.Value <string>("Artist"), title = obj.Value.Value <string>("Title"), cover = obj.Value.Value <string>("Cover"), listenedTo = obj.Value.Value <bool>("Listened to") }); } } return(list); }
public Window() { Albums = GetAlbums(); InitializeComponent(); }