-1

Is the StaticPropertyChanged event simply a convention (regarding names) or what mechanism does WPF use to recognize this event?

BennoDual
  • 5,865
  • 15
  • 67
  • 153

1 Answers1

1

The eventhandler raising static property change notification must have one of two possible signatures.

Note that it must be static itself, so it cannot just be a regular propertychanged eventhandler

This is explained here:

https://learn.microsoft.com/en-us/dotnet/desktop/wpf/getting-started/whats-new?redirectedfrom=MSDN&view=netframeworkdesktop-4.8#static_properties

Binding to static properties

You can use static properties as the source of a data binding. The data binding engine recognizes when the property's value changes if a static event is raised. For example, if the class SomeClass defines a static property called MyProperty, SomeClass can define a static event that is raised when the value of MyProperty changes. The static event can use either of the following signatures.

public static event EventHandler MyPropertyChanged;

public static event EventHandler StaticPropertyChanged;

Note that in the first case, the class exposes a static event named PropertyNameChanged that passes EventArgs to the event handler. In the second case, the class exposes a static event named StaticPropertyChanged that passes PropertyChangedEventArgs to the event handler. A class that implements the static property can choose to raise property-change notifications using either method.

Andy
  • 11,864
  • 2
  • 17
  • 20