/// <summary> /// Add all Taxa in groups based on their OrderName. /// </summary> /// <param name="selectedTaxonListSource">The List of currently displayed Taxa to add in groups.</param> private void AddListsToGroups(IEnumerable <Taxon> selectedTaxonListSource) { SelectedTaxonList.Clear(); foreach (var shownItem in selectedTaxonListSource) { if (SelectedTaxonList.Any(i => i.OrderName == shownItem.OrderName)) { SelectedTaxonList.FirstOrDefault(i => i.OrderName == shownItem.OrderName).Add(shownItem); } else { SelectedTaxonList.Add(new TaxonListGroup(shownItem.OrderName, shownItem.OrderLocalName) { shownItem }); } } foreach (var hiddenItem in HiddenTaxonList) { if (!SelectedTaxonList.Any(i => i.OrderName == hiddenItem.OrderName)) { SelectedTaxonList.Add(new TaxonListGroup(hiddenItem.OrderName, hiddenItem.OrderLocalName)); } } SortObservableList(SelectedTaxonList); }
/// <summary> /// Remove Taxa without Diagnosis from underlying List-source, add lists to groups /// </summary> public void UpdateSelectedTaxonListSource() { SelectedTaxonListSource.RemoveAll(i => !i.HasDiagnosis); PlaceholderText = $"Suchen in {SelectedTaxonListSource.Count} Arten"; OnPropertyChanged(nameof(PlaceholderText)); SelectedTaxonList.Clear(); AddListsToGroups(SelectedTaxonListSource.OrderBy(i => i.LocalName).ThenBy(i => i.TaxonName)); SelectedTaxonList.RefreshView(); OnPropertyChanged(nameof(SelectedTaxonList)); }