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屬性, 您應該使用做為最常見的「取得」作業。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.

未設定任何本機值時, 這個方法UnsetValue會傳回。When 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.

適用於

另請參閱