Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could have a look at <a href="http://www.sharpcrafters.com/" rel="noreferrer">PostSharp</a>. They even have a sample at <a href="http://www.sharpcrafters.com/solutions/notifypropertychanged" rel="noreferrer">Data Binding</a>. The code taken from there:</p> <pre><code>/// &lt;summary&gt; /// Aspect that, when apply on a class, fully implements the interface /// &lt;see cref="INotifyPropertyChanged"/&gt; into that class, and overrides all properties to /// that they raise the event &lt;see cref="INotifyPropertyChanged.PropertyChanged"/&gt;. /// &lt;/summary&gt; [Serializable] [IntroduceInterface( typeof(INotifyPropertyChanged), OverrideAction = InterfaceOverrideAction.Ignore )] [MulticastAttributeUsage( MulticastTargets.Class, Inheritance = MulticastInheritance.Strict )] public sealed class NotifyPropertyChangedAttribute : InstanceLevelAspect, INotifyPropertyChanged { /// &lt;summary&gt; /// Field bound at runtime to a delegate of the method &lt;c&gt;OnPropertyChanged&lt;/c&gt;. /// &lt;/summary&gt; [ImportMember( "OnPropertyChanged", IsRequired = false)] public Action&lt;string&gt; OnPropertyChangedMethod; /// &lt;summary&gt; /// Method introduced in the target type (unless it is already present); /// raises the &lt;see cref="PropertyChanged"/&gt; event. /// &lt;/summary&gt; /// &lt;param name="propertyName"&gt;Name of the property.&lt;/param&gt; [IntroduceMember( Visibility = Visibility.Family, IsVirtual = true, OverrideAction = MemberOverrideAction.Ignore )] public void OnPropertyChanged( string propertyName ) { if ( this.PropertyChanged != null ) { this.PropertyChanged( this.Instance, new PropertyChangedEventArgs( propertyName ) ); } } /// &lt;summary&gt; /// Event introduced in the target type (unless it is already present); /// raised whenever a property has changed. /// &lt;/summary&gt; [IntroduceMember( OverrideAction = MemberOverrideAction.Ignore )] public event PropertyChangedEventHandler PropertyChanged; /// &lt;summary&gt; /// Method intercepting any call to a property setter. /// &lt;/summary&gt; /// &lt;param name="args"&gt;Aspect arguments.&lt;/param&gt; [OnLocationSetValueAdvice, MulticastPointcut( Targets = MulticastTargets.Property, Attributes = MulticastAttributes.Instance)] public void OnPropertySet( LocationInterceptionArgs args ) { // Don't go further if the new value is equal to the old one. // (Possibly use object.Equals here). if ( args.Value == args.GetCurrentValue() ) return; // Actually sets the value. args.ProceedSetValue(); // Invoke method OnPropertyChanged (our, the base one, or the overridden one). this.OnPropertyChangedMethod.Invoke( args.Location.Name ); } } </code></pre> <p>Usage is then as simple as this:</p> <pre><code>[NotifyPropertyChanged] public class Shape { public double X { get; set; } public double Y { get; set; } } </code></pre> <p>Examples taken from PostSharp site and inserted for completing the answer</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload