I am working on creating a base view model class. ViewModelBase is an abstract class and I want to define the properties that I want all my other derived view models to implement.
One of the properties is an ObservableCollection:
public abstract ObservableCollection<???> Items { get; set; }
The classes that derive from this base class will have different types of Items defined (ObservableCollection<Person>, ObservableCollection<Car>).
If I set the ObservableCollection type to object in ViewModelBase, it would require me to do a lot of different casting in the derived classes to get it to work.
Is this the right approach?
I’m not quite sure why you would want to make it so generic, but if you did, I’d recommend that you make the abstract base class generic as well:
I hope you also make sure that your ViewModelBase implements INotifyPropertyChanged.