DependencyObject.ReadLocalValue(DependencyProperty) 方法


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

 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



要检索其值的属性的 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.