PropertyChangedBase vs INotifyPropertyChanged

1544
1
10-28-2019 07:16 AM
Vidar
by
Occasional Contributor II

Hi,

I was just wondering why I have to use PropertyChangedBase vs INotifyPropertyChanged when creating my viewmodel. With normal vanilla WPF programming it's always INotifyPropertyChanged so there must be something special about PropertyChangedBase.

Tags (2)
0 Kudos
1 Reply
JohnJones
Esri Contributor

PropertyChangedBase is an abstract base class, from which you may derive your VM classes; it implements INotifyPropertyChanged which is a .NET interface which just provides an event which clients can listen to in order to receive notification about properties changing (views via data binding will use this event to receive notification that the VM has changed).  As PropertyChangedBase provides additional help in firing this event (via NotifyPropertyChanged & SetProperty helpers) you can make use of it as long as you don't have another class to inherit from.  As C# only allows for single inheritance though if you need to inherit from a different base class for any reason (that doesn't itself implement INotifyPropertyChanged) than although you cannot also inherit from PropertyChangedBase you can implement the INotifyPropertyChanged interface and still provide the needed interface so that binding in WPF views works as expected.  Aside from providing the NotifyPropertyChanged & SetProperty methods to help with firing PropertyChanged events and thus forming the base class of the other ArcGIS Pro framework classes (DockPane, Tool, Command etc) there is not anything 'special' about its implementation of INotifyPropertyChanged.