MVVM / ObservableCollection Question

后端 未结 6 942
陌清茗
陌清茗 2021-01-19 15:32

I have the following XAML:

   
        

        
6条回答
  •  臣服心动
    2021-01-19 15:58

    As long as the property holding the collection has been created before the list is bound/DataContext set, you should be ok. If the collection is replaced, as @Phil Sandler says, you need to notify. If you create you only perform new when declaring the variable, or inside of the constructor of the class, you should not need notify property changed for that property. If you need to clear the list, I would recommend using the Clear method of the collection, and not replace it.

提交回复
热议问题