/// <summary> /// Reload the LogEntryRowViewModels then update counters and update the selectedlogitem /// </summary> /// <param name="repositories">Repositories containing the entries</param> public void SetEntries(List <RepositoryViewModel> repositories) { Application.Current.Dispatcher.Invoke( DispatcherPriority.Normal, (Action) delegate { RemoveAllItems(); foreach (RepositoryViewModel repo in repositories) { if (repo.Active) { foreach (LogEntry entry in repo.Repository.LogEntries) { var entryRow = new LogEntryRowViewModel(entry); entryRow.UpdateTextMarkerQuantity(); LogEntryRowViewModels.Add(entryRow); } } } SelectedLogItem = LogEntryRowViewModels.Any() ? LogEntryRowViewModels.Last() : null; UpdateCounters(); }); }
/// <summary> /// Build a CollectionView on top of an observable collection. /// This is required to implemented Filter and Group Features /// for a DataGrid in an MVVM fashion. /// </summary> /// <param name="items"></param> private void RebuildLogView(ObservableCollection <LogEntryRowViewModel> items) { if (LogEntryRowViewModels != null) { foreach (LogEntryRowViewModel item in items) { LogEntryRowViewModels.Add(item); } } else { LogEntryRowViewModels = new ObservableCollection <LogEntryRowViewModel>(); } LogView = (CollectionView)CollectionViewSource.GetDefaultView(LogEntryRowViewModels); LogView.Filter = OnFilterLogItems; RefreshView(); }