Skip to content

Commit

Permalink
fix #236:
Browse files Browse the repository at this point in the history
per http://www.blackwasp.co.uk/WPFItemsSource.aspx where it says:

> When ItemsSource is set, the Items property cannot be used to control the displayed values. If you later set ItemsSource to null, Items becomes usable again.

Flipped the ItemSource nulling and clearing of the list.
  • Loading branch information
GerHobbelt committed Oct 8, 2020
1 parent 0949df1 commit bce0d60
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using icons;
Expand Down Expand Up @@ -83,7 +84,7 @@ internal void ShowTagOptions(Library library_, List<PDFDocument> pdf_documents_,
pdf_documents = pdf_documents_;
OnShowTagOptionsComplete = OnShowTagOptionsComplete_;

// Collate all the availalbe tags
// Collate all the available tags
HashSet<string> all_tags = new HashSet<string>();
HashSet<string> all_creators = new HashSet<string>();
foreach (var pdf_document in pdf_documents)
Expand Down Expand Up @@ -116,12 +117,14 @@ internal void ShowTagOptions(Library library_, List<PDFDocument> pdf_documents_,

List<string> all_creators_sorted = new List<string>(all_creators);
all_creators_sorted.Sort();
ObjFilterByCreatorCombo.ItemsSource = all_creators_sorted;

List<string> bindable_tags = new List<string>(all_tags);
bindable_tags.Add(HighlightToAnnotationGenerator.HIGHLIGHTS_TAG);
bindable_tags.Add(InkToAnnotationGenerator.INKS_TAG);
bindable_tags.Sort();
ObservableCollection<string> all_creators_source = new ObservableCollection<string>(all_creators_sorted);
ObjFilterByCreatorCombo.ItemsSource = all_creators_source;

all_tags.Add(HighlightToAnnotationGenerator.HIGHLIGHTS_TAG);
all_tags.Add(InkToAnnotationGenerator.INKS_TAG);
List<string> all_tags_sorted = new List<string>(all_tags);
all_tags_sorted.Sort();
ObservableCollection<string> bindable_tags = new ObservableCollection<string>(all_tags_sorted);
ListTags.Items.Clear();
ListTags.ItemsSource = bindable_tags;

Expand Down Expand Up @@ -190,9 +193,8 @@ protected override void OnClosed(EventArgs e)
pdf_documents.Clear();
pdf_documents = null;

ListTags.Items.Clear();
ListTags.ItemsSource = null;

ListTags.Items.Clear();
}
}
}

0 comments on commit bce0d60

Please sign in to comment.