Hi All,
I'm sure there's an "easy" answer to this, but for the moment it escapes me.
In an MVVM application, I have a property that is a ObservableCollection, used for displaying some set of elements on the view.
private readonly ObservableCollection<MyType> mMyCollection =
new ObservableCollection<MyType>();
public ObservableCollection<MyType> MyCollection
{
get { return mMyCollection; }
}
I want to restrict consumers of this collection from simply using the property to add to the collection (i.e. I want to prevent this from the view):
viewModel.MyCollection.Add(newThing); // want to prevent this!
Instead, I want to force the use of a method to add items, because there may be another thread using that collection, and I don't want to modify the collection while that thread is processing it.
public void AddToMyCollection(MyType newItem)
{
// Do some thread/task stuff here
}
Thanks, wTs