How can I make a read-only ObservableCollection property?

前端 未结 5 1660
你的背包
你的背包 2021-01-03 17:55

I\'d like to expose a property on a view model that contains a list of objects (from database).

I need this collection to be read-only. That is, I want to prevent A

5条回答
  •  星月不相逢
    2021-01-03 18:19

    You could also override the list class that you're using and put an immutable flag in one of the constructors such that it will not add/remove if it was constructed with the immutable flag set to true.

提交回复
热议问题