public ReportsViewModel( ISynchronizationReportRepository reportRepository, Dictionary <Guid, string> currentProfileNamesById, IReportsViewModelParent parent) { _reportRepository = reportRepository; _currentProfileNamesById = currentProfileNamesById; _parent = parent; _deleteSelectedCommand = new DelegateCommand(DeleteSelected, _ => _reports.Any(r => r.IsSelected)); _saveSelectedCommand = new DelegateCommand(SaveSelected, _ => _reports.Any(r => r.IsSelected)); foreach (var reportName in reportRepository.GetAvailableReports()) { AddReportViewModel(reportName); } // Regarding to race conditions it doesn't matter when the handler is added // since everything happens in the ui thread _reportRepository.ReportAdded += ReportRepository_ReportAdded; _reportsCollectionViewSource = new CollectionViewSource(); _reportsCollectionViewSource.Source = _reports; _reportsCollectionViewSource.SortDescriptions.Add(new SortDescription(nameof(ReportViewModel.StartTime), ListSortDirection.Descending)); Reports = _reportsCollectionViewSource.View; if (_reports.Count > 0) { _reports[0].IsSelected = true; } }
public ReportsViewModel ( ISynchronizationReportRepository reportRepository, Dictionary<Guid, string> currentProfileNamesById, IReportsViewModelParent parent) { _reportRepository = reportRepository; _currentProfileNamesById = currentProfileNamesById; _parent = parent; _deleteSelectedCommand = new DelegateCommand (DeleteSelected, _ => Reports.Any (r => r.IsSelected)); _saveSelectedCommand = new DelegateCommand (SaveSelected, _ => Reports.Any (r => r.IsSelected)); foreach (var reportName in reportRepository.GetAvailableReports()) AddReportViewModel (reportName); // Regarding to race conditions it doesn't matter when the handler is added // since everything happens in the ui thread _reportRepository.ReportAdded += ReportRepository_ReportAdded; if (Reports.Count > 0) Reports[0].IsSelected = true; }
public ReportsViewModel( ISynchronizationReportRepository reportRepository, Dictionary <Guid, string> currentProfileNamesById, IReportsViewModelParent parent) { _reportRepository = reportRepository; _currentProfileNamesById = currentProfileNamesById; _parent = parent; _deleteSelectedCommand = new DelegateCommand(DeleteSelected, _ => Reports.Any(r => r.IsSelected)); _saveSelectedCommand = new DelegateCommand(SaveSelected, _ => Reports.Any(r => r.IsSelected)); foreach (var reportName in reportRepository.GetAvailableReports()) { AddReportViewModel(reportName); } // Regarding to race conditions it doesn't matter when the handler is added // since everything happens in the ui thread _reportRepository.ReportAdded += ReportRepository_ReportAdded; if (Reports.Count > 0) { Reports[0].IsSelected = true; } }