DependencyPropertyChangedEventArgs class

Provides data for a PropertyChangedCallback implementation that is invoked when a dependency property changes its value. Also provides event data for the Control.IsEnabledChanged event and any other event that uses the DependencyPropertyChangedEventHandler delegate.




public sealed class DependencyPropertyChangedEventArgs


The DependencyPropertyChangedEventArgs class has these types of members:


The DependencyPropertyChangedEventArgs class inherits methods from the Object class.


The DependencyPropertyChangedEventArgs class has these properties.

PropertyAccess typeDescription


Read-onlyGets the value of the dependency property after the reported change.


Read-onlyGets the value of the dependency property before the reported change.


Read-onlyGets the identifier for the dependency property where the value change occurred.



DependencyPropertyChangedEventArgs provides data for two different situations that involve changes to dependency property values:

A PropertyChangedCallback implementation is an optional part of the property metadata that you provide when you register a dependency property. The callback is invoked by the dependency property system internally. For more info on dependency properties in general, see Dependency properties overview.

Typically you define the method with private or internal access. The method must be static. Because the method is static, the DependencyObject parameter (d) of the PropertyChangedCallback delegate is important. That's what identifies the specific dependency object instance where the property is changing. For many operations, such as correcting or coercing a value, or changing another calculated property value in response on the same object, you'll reference this DependencyObject. You'll typically want to cast it to the owner type of the property that changes. The owner type is the type referenced by name in the DependencyProperty.Register call; the metadata where your PropertyChangedCallback is assigned to property metadata is part of that same call.

Be aware of the possibility for recursion. If you change the value of a dependency property that the PropertyChangedCallback is invoked for, it will be invoked again. For example, if you created a callback for a Double property where the callback always divided the value by 2, that callback would be called recursively and your app would be in an infinite loop.

It's legal to have two or more different dependency properties define callbacks to change each other, but again be careful to not create an unintentional circular dependency that doesn't enable the values to stabilize.

A PropertyChangedCallback is only invoked if OldValue and NewValue in the event data is different.

OldValue and NewValue come untyped, so any comparison you perform probably needs a cast. Many dependency property values are using a value type, which means you'll be relying on the operators or other APIs of the value type to make the comparisons. That functionality is usually available on the structure that represents a value, as a utility API. For example, the language-specific utility API on a Thickness value enables you to compare Thickness values.

Note  If you are programming using C++, a few of the Windows Runtime structures don't support nondata members, so don't support operators or other utility. For these, there is a companion Helper class that provides comparison APIs that C++ code can use. For example, use the ColorHelper class to compare Color values.

Using DependencyPropertyChangedEventArgs for a custom event

A custom control implementer might consider using DependencyPropertyChangedEventHandler as the delegate type if a custom event is fired as a result of a dependency property value change. You can only fire such an event from within the context of a PropertyChangedCallback. This is because the value that changed (the property, the old and new value) should be in the DependencyPropertyChangedEventArgs that are reported for the event at the property-system level. But there aren't any constructors for DependencyPropertyChangedEventArgs and none of its properties are settable, so the only way to get a DependencyPropertyChangedEventArgs value is to get it from the original PropertyChangedCallback parameters and pass it through when you fire your custom event.


This example shows a PropertyChangedCallback implementation that uses the DependencyPropertyChangedEventArgs event data. In particular, it uses NewValue to set a related property, which displays the underlying numeric DependencyProperty value as text, in a TextBlock part of a composite control.

private static void ValueChangedCallback(DependencyObject obj, DependencyPropertyChangedEventArgs args)
    NumericUpDown ctl = (NumericUpDown)obj;
    Int32 newValue = (Int32)args.NewValue;

    // Update the TextElement to the new value.
    if (ctl.TextElement != null)
        ctl.TextElement.Text = newValue.ToString();

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::UI::Xaml [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]


Windows::UI::Xaml [C++]





See also

Custom dependency properties
Dependency properties overview



© 2015 Microsoft