public FreePlayViewModel() { TuneResultData targetData = new TuneResultData(); List <TuneResultContent> items = new List <TuneResultContent> (); // new Task (() => { items = targetData.Read(); if (FreePlaysList == null || FreePlaysList.Count != items.Count) { List <UserModel> itemsForBinding = new List <UserModel> (); for (int i = 0; i < items.Count; i++) { StringBuilder contentBuilder = new StringBuilder(items [i].album); contentBuilder.Append(" - "); contentBuilder.Append(items [i].length); UserModel single = new UserModel { Id = items [i].uniqueid, Avatar = items [i].artURL, Name = items [i].artist, Content = contentBuilder.ToString(), Value = 0 }; itemsForBinding.Add(single); } FreePlaysList = new ObservableCollection <UserModel> (itemsForBinding); } //}).Start(); }
public HistoryViewModel() { HistoryList = new ObservableCollection <UserModel> (); new Task(() => { TuneResultData targetData = new TuneResultData(); List <TuneResultContent> items = new List <TuneResultContent> (); items = targetData.Read(); items = items.FindAll(x => x.isHistory); HistoryList = new ObservableCollection <UserModel> (); for (int i = 0; i < items.Count; i++) { HistoryList.Add(new UserModel { Id = items [i].uniqueid, Avatar = items [i].artURL, Name = items [i].artist, Content = String.Format("{0} - {1}", items [i].album, items [i].length), Value = 0 }); } }).Start(); }