ErikTJ
ErikTJ

Reputation: 2009

Must resize window for items to show

I have a ListView which I have bound with a List. If I add items to the List I must resize my window for the items to appear in my ListView.

Any ideas?

Upvotes: 2

Views: 123

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564851

Make sure your list implements INotifyCollectionChanged. You may want to use ObservableCollection<T> here, as it makes this easy.

If you are binding to a standard List<T>, there is no way for the binding system to know that the list's contents have changed. My guess is that, when you resize the window, the list is rechecking the binding (in order to perform the new layout correctly), and capturing the new elements. Until you do this, the list's binding never refreshes. INotifyCollectionChanged will fix that.

Upvotes: 1

Related Questions