C# WPF MVVM – Alternatives to ObservableCollection

cmvvmwpf

I am new to wpf c# and MVVM approach. I have a working program that demonstrate the MVVM approach in wpf c# (by copying some code from the internet and applying it to may program). I have used ObservableCollection in my viewmodel and add my own object here. As I have said, it is working fin but the problem is I only have a single object. The question is how can I use RaisePropertyChanged to my object without using ObservableCollection? Is there a class that can trigger the change property of a single object or the only way is using ObservableCollection and add may only object to it? Please help me, all the examples I have seen in the internet is using ObservableCollection.

Best Answer

In general, your view model should be implementing INotifyPropertyChanged. It should then fire the PropertyChanged event whenever a property that the view is listening changes, and this will be picked up by the WPF framework. As you suspect, ObservableCollection is only for when you have a collection of things you want to monitor.

Related Topic