DependencyObject.ReadLocalValue method

Expand
This topic has not yet been rated - Rate this topic

DependencyObject.ReadLocalValue method

[This documentation is preliminary and is subject to change.]

Returns the local value of a dependency property, if a local value is set.

Syntax


public object ReadLocalValue(
  DependencyProperty dp
)

Parameters

dp

Type: DependencyProperty

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

Return value

Type: System.Object [.NET] | Platform::Object [C++]

Returns the local value, or returns the sentinel value UnsetValue if no local value is set.

Examples

This example checks for an existing local value with ReadLocalValue. If there is a local value, as indicated by not returning UnsetValue, then the existing local value is removed by calling ClearValue.


public static bool ClearSetProperty(DependencyObject targetObject, DependencyProperty targetDP)
{
    if (targetObject == null || targetDP == null)
    {
        throw new ArgumentNullException();
    }
    object localValue = targetObject.ReadLocalValue(targetDP);
    if (localValue == DependencyProperty.UnsetValue)
    {
        return false;
    }
    else
    {
        targetObject.ClearValue(targetDP);
        return true;
    }
}


Requirements

Minimum supported client

Windows 8 Release Preview

Minimum supported server

Windows Server 2012

Namespace

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

Metadata

Windows.winmd

See also

DependencyObject
Dependency properties overview

 

 

Build date: 5/22/2012

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD