DependencyObject.GetValue(DependencyProperty) Method


傳回 DependencyObject 的這個執行個體上之相依性屬性的目前有效值。Returns the current effective value of a dependency property on this instance of a DependencyObject.

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



要擷取其值之屬性的 DependencyProperty 識別項。The DependencyProperty identifier of the property to retrieve the value for.



傳回目前有效值。Returns the current effective value.


指定的 dp 或其值無效,或是指定的 dp 不存在。The specified dp or its value was invalid, or the specified dp does not exist.


有效值是屬性系統傳回給要求值之任何呼叫端的屬性值。The effective value is the value of the property that is returned by the property system to any caller that is requesting the value. 有效值是屬性系統已評估所有參與屬性系統值優先順序之可能輸入的結果。The effective value is the result of the property system having evaluated all the possible inputs that participate in the property system value precedence. 這包括強制型轉和動畫。This includes coercion and animation. 如需詳細資訊,請參閱相依性屬性值優先順序For more information, see Dependency Property Value Precedence.

這個方法永遠不會傳回 UnsetValueThis method will never return UnsetValue. UnsetValue 是內部使用的屬性系統的 sentinel 值,而且偶爾也會透過強制回呼來公開。The UnsetValue is a sentinel value for the property system that is used in various capacities internally and occasionally also exposed through coercion callbacks.

如果您不確定該屬性的類型為何,您可以查詢所要求之相依性屬性的識別碼,以判斷是否有更具體的 PropertyType 可將傳回值轉換成。If you are not sure what the property's type should be, you can query the identifier of the requested dependency property to determine whether there is a more specific PropertyType that the return value can be converted to.

Applies to

See also