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.


針對相依性屬性的最常見「取得」作業,您應該使用 GetValueYou 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.