DependencyObject.ReadLocalValue(DependencyProperty) DependencyObject.ReadLocalValue(DependencyProperty) DependencyObject.ReadLocalValue(DependencyProperty) DependencyObject.ReadLocalValue(DependencyProperty) Method

定义

如果存在,则返回依赖属性的本地值。Returns the local value of a dependency property, if it exists.

public:
 System::Object ^ ReadLocalValue(System::Windows::DependencyProperty ^ dp);
public object ReadLocalValue (System.Windows.DependencyProperty dp);
member this.ReadLocalValue : System.Windows.DependencyProperty -> obj
Public Function ReadLocalValue (dp As DependencyProperty) As Object

参数

dp
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

要为其检索值的属性的 DependencyProperty 标识符。The DependencyProperty identifier of the property to retrieve the value for.

返回

返回本地值,或在未设置本地值的情况下返回 sentinel 值 UnsetValueReturns the local value, or returns the sentinel value UnsetValue if no local value is set.

注解

对于依赖属性GetValue , 您应使用最典型的 "get" 操作。You should use GetValue for most typical "get" operations for a dependency property. ReadLocalValue如果值不是本地设置的, 则不会返回有效的值。ReadLocalValue does not return the effective value for a variety of circumstances where the value was not locally set.

由 "样式"、"主题"、"模板"、"元数据" 或 "属性值继承" 的默认值设置的值不被视为本地值。Values that are set by styles, themes, templates, the default value from metadata, or property value inheritance are not considered to be local values. 但是, 在计算绑定和其他表达式后, 它们被视为本地值。However, bindings and other expressions are considered to be local values, after they have been evaluated.

如果未设置本地值, 则此方法返回UnsetValueWhen no local value is set, this method returns UnsetValue.

如果返回的值不是UnsetValue, 则可以查询请求的依赖项属性的元数据, 以确定是否有更具体的类型可以将返回值转换为。If the returned value is other than UnsetValue, you can query the metadata of the requested dependency property to determine whether there is a more specific type that the return value can be converted to.

适用于

另请参阅