This is the online documentation for PostSharp 5.0.
Download PDF or CHM. Go to v4.3 or v5.0


Binding objects to the UI is a large and tedious task. You must implement INotifyPropertyChanged on every property that needs to be bound. You need to ensure that the underlying property setter correctly raises events so that the View knows that changes have occurred. The larger your codebase, the more work there is. You can partially eliminate all of this repetitive code by pushing some of the functionality to a base class that each Model class inherits from. It still doesn't eliminate all of the repetition though.

PostSharp can completely eliminate all of that repetition for you. PostSharp's NotifyPropertyChangedAttribute has the following features and benefits:

  • Supports computed properties.

  • Supports computed properties referencing child objects, e.g. string FullName => this.model.FirstName + " " + this.model.LastName.

  • Raises the PropertyChanged at the right moment, when all class invariants are valid.

  • Fully customizable. Can be integrated with other MVVM frameworks.

  • High-performance. Almost as fast as handwritten code.

In this chapter



Implementing INotifyPropertyChanged

This section shows how to automatically implement the INotifyPropertyChanged interface in a class thanks to the NotifyPropertyChangedAttribute aspect.

Working with Properties that Depend on Other Objects

This section describes how to handle dependencies that cross several objects, as when a view-model object is dependent on properties of a model object.

Implementing INotifyPropertyChanging

This section documents how to implement the INotifyPropertyChanging interface for components which need to be signalled before a property value is changed.

Integrating with UI Frameworks

This section shows examples of using the NotifyPropertyChangedAttribute aspect with some of the popular UI frameworks.

Handling Corner Cases

This section documents how to cope with the cases that cannot be automatically handled by the NotifyPropertyChangedAttribute aspect.

Understanding the NotifyPropertyChanged Aspect

This section describes the principles and concepts on which the NotifyPropertyChangedAttribute aspect relies.

Suppressing False Positives

This section shows how to prevent notifications when the property value does not actually change.