Why doesn't a ListBox bound to an IEnumerable update?

后端 未结 1 1299
独厮守ぢ
独厮守ぢ 2021-01-28 22:33

I have the following XAML:



        
相关标签:
1条回答
  • 2021-01-28 22:57

    Raising the PropertyChanged event for the Items property is only effective if the property value has actually changed. While you raise the event, the WPF binding infrastructure notices that the collection instance returned by the property getter is the same as before and does nothing do update the binding target.

    However, when you return items.Values.ToList(), a new collection instance is created each time, and the binding target is updated.

    0 讨论(0)
提交回复
热议问题