As an addition to @Sweeper's answer, you can accomplish the same using event handler method, without the burden of lambda expressions:
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
...
}
}
Which you can then use to subscribe to the PropertyChanged
event:
p.PropertyChanged += OnPropertyChanged;
And to unsubscribe:
p.PropertyChanged -= OnPropertyChanged;
Additional info from the docs:
To respond to an event, you define an event handler method in the event receiver. This method must match the signature of the delegate for the event you are handling. In the event handler, you perform the actions that are required when the event is raised, such as collecting user input after the user clicks a button. To receive notifications when the event occurs, your event handler method must subscribe to the event.