DependencyPropertyChangedEventArgs.Property Property

Definition

Gets the identifier for the dependency property where the value change occurred.

C#
public DependencyProperty Property { get; }

Property Value

The identifier field of the dependency property where the value change occurred.

Remarks

In many cases the dependency property being changed is known implicitly, because you're checking the DependencyPropertyChangedEventArgs data in a callback that's dedicated for use only by one defined dependency property. The Property property makes it possible to share a PropertyChangedCallback as a common callback for more than one PropertyMetadata instance and more than one dependency property. For example, you might have handler logic that first checks Property and then branches behavior (like knowing how to cast NewValue) depending on which property's change invoked the handler in this event case:

C#
private static void OnGravityPropertiesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
    if (e.Property==Planet.GravityFactorProperty) {
        //GravityFactor is a Double, cast e.NewValue to Double, do logic
    }
    if (e.Property==Planet.IsGravityOnProperty) {
        //IsGravityOn is a Boolean, cast e.NewValue to Boolean, do logic
    }
}

Applies to

Product Versions
Windows App SDK 0.8, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6

See also