GetValue Method

DependencyObject.GetValue Method (DependencyProperty)


Returns the current effective value of a on this instance of a DependencyObject. GTMT

Namespace:   System.Windows
Assembly:  WindowsBase (in WindowsBase.dll)

public object GetValue(
	DependencyProperty dp


Type: System.Windows.DependencyProperty

The DependencyProperty identifier of the property to retrieve the value for.

Return Value

Type: System.Object

Returns the current effective value.

Exception Condition

The specified dp or its value was invalid, or the specified dp does not exist.

The effective value is the value of the property that is returned by the property system to any caller that is requesting the value. The effective value is the result of the property system having evaluated all the possible inputs that participate in the property system value precedence. This includes coercion and animation. For more information, see Dependency Property Value Precedence.

This method will never return UnsetValue. The UnsetValue is a sentinel value for the property system that is used in various capacities internally and occasionally also exposed through coercion callbacks.

If you are not sure what the property's type should be, you can query the identifier of the requested dependency property to determine whether there is a more specific PropertyType that the return value can be converted to.

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2015 Microsoft