Skip to content

Attributes

SimonCropp edited this page Mar 17, 2013 · 3 revisions

ImplementPropertyChangingAttribute

Allows the injection of the INotifyPropertyChanging interface.

[ImplementPropertyChanging]
public class Person 
{
    public string Name { get; set; }
}

AlsoNotifyFor Property

Allows the injection of notify code that points to a different property.

For example

public class Person : INotifyPropertyChanged
{
    [AlsoNotifyFor("FullName")]
    public string GivenName { get; set; }

    [AlsoNotifyFor("FullName")]
    public string FamilyName { get; set; }

    public event PropertyChangedEventHandler PropertyChanged;

    public string FullName { get; set; }
}

DoNotNotifyAttribute

Use this attribute to exclude a property or type from having notification injected.

For Example

public class Person : INotifyPropertyChanged
{
    public string GivenName { get; set; }
    [DoNotNotify]
    public string FamilyName { get; set; }
    public event PropertyChangedEventHandler PropertyChanged;
}

DependsOnAttribute

Injects this property to be notified when a dependent property is set.

For Example

public class Person : INotifyPropertyChanged
{
    public string GivenName { get; set; }

    public string FamilyName { get; set; }

    public event PropertyChangedEventHandler PropertyChanged;

    [DependsOn("GivenName","FamilyName")]
    public string FullName { get; set; }
}