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 开发者_如何学JAVAitems to appear in my ListView
.
Any ideas?
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.
精彩评论