Skip to content

EventInvokerSelectionInjection

SimonCropp edited this page Mar 21, 2013 · 3 revisions

Introduction

Event invoker is the method that actually fires the PropertyChanged event. Although it is not part of the INotifyPropertyChanged interface the standard form is as follows

public virtual void OnPropertyChanged(string propertyName)
{
    var propertyChanged = PropertyChanged;
    if (propertyChanged != null)
    {
        propertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}

Event Invoker Name

The name of the event invoker method can be changed (from its default of OnPropertyChanged) using the EventInvokerNames property.

For example if you are using the Caliburn base class the following could be used

<Weavers>
  <PropertyChanged EventInvokerNames="RaisePropertyChange"/>
</Weavers>

So in all examples you can exchange "OnPropertyChanged" with whatever you have selected using EventInvokerNames.

Note: you actually do not need to set EventInvokerNames for Caliburn because it is automatically derived. See SupportedToolkits

Method Selection / Injection

The event invoker call is done as follows

  • Try to find a method with the following signature in the class hierarchy (where method name matches EventInvokerNames) OnPropertyChanged(string propertyName)
  • If no method is found then the standard OnPropertyChanged code (listed above) is injected.