public AlbumsLitstViewModel(IMusicDataService dataService, IEventAggregator eventAggregator) { if (dataService == null) { throw new ArgumentNullException("dataService"); } if (eventAggregator == null) { throw new ArgumentNullException("eventAggregator"); } this.dataService = dataService; this.eventAggregator = eventAggregator; this.Albums = new ListCollectionView(dataService.GetAlbums()); this.Albums.CurrentChanged += new EventHandler(this.SelectedAlbumChanged); }
public ArtistListViewModel(IMusicDataService dataService, IEventAggregator eventAggregator) { if (dataService == null) { throw new ArgumentNullException("dataService"); } if (eventAggregator == null) { throw new ArgumentNullException("eventAggregator"); } this.dataService = dataService; this.eventAggregator = eventAggregator; var item = dataService.GetAlbums().Select(x => x.Artist).Distinct(); var distintc = item.GroupBy(x => x.ArtistId).Select(x => x.First()); this.Artists = new ListCollectionView(new ObservableCollection <Model.Artist>().AddRange(distintc.ToList())); this.Artists.CurrentChanged += new EventHandler(this.SelectedArtistChanged); }