Returns the current effective value of a dependency property from a DependencyObject.
Syntax
Parameters
- dp
-
Type: DependencyProperty
The DependencyProperty identifier of the property for which to retrieve the value.
Return value
Type: System.Object [.NET] | Platform::Object [C++]
Returns the current effective value.
Remarks
GetValue obtains the current effective value of a dependency property. The current effective value is determined by using rules of dependency property precedence.
GetValue is the API you want in most cases if you are using the property system APIs for obtaining property values. But sometimes you might want to examine other values to see how the dependency property precedence is acting for a given property. If so, you can use one of these APIs:
- GetAnimationBaseValue to get values that might currently be animated but you want to know the value before the animation ran. Note that animations with HoldEnd behavior might not have this same value. For more info on the HoldEnd concept, see Storyboarded animations.
- ReadLocalValue to get the local value, which does not have styles or templates or animations applied. Bindings do count as local values, but depending on when you call ReadLocalValue, the acting binding context might not be available yet, so you won't get the same value as would be applied at run time.
For more info on dependency property precedence and other property system utility API, see Dependency properties overview.
Examples
This example shows a simple dependency property declaration. A call to GetValue constitutes the entirety of the get accessor implementation for the property wrapper of the new dependency property. For more examples, see Custom dependency properties.
public class Fish : Control { public static readonly DependencyProperty SpeciesProperty = DependencyProperty.Register( "Species", typeof(String), typeof(Fish), null ); public string Species { get { return (string)GetValue(SpeciesProperty); } set { SetValue(SpeciesProperty, (string)value); } } }
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 1/31/2013