DependencyObject.GetValue(DependencyProperty) 方法

定義

回傳此實例 DependencyObject上依賴屬性的當前有效值。

public:
 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

參數

dp
DependencyProperty

DependencyProperty 取得該值的屬性識別碼。

傳回

回傳當前有效價值。

例外狀況

指定 dp 值或其值無效,或是指定 dp 不存在。

備註

有效值是屬性系統回傳給任何請求該值的呼叫者所擁有的屬性值。 有效價值是屬性系統評估所有可能參與屬性系統價值優先順序的輸入的結果。 這包括脅迫和動畫。 欲了解更多資訊,請參閱 「相依財產價值優先次序」。

此方法永遠不會返回 UnsetValue。 這是 UnsetValue 財產系統的哨兵價值,內部多種用途,有時也會透過強制回調曝光。

如果你不確定屬性的類型應該是什麼,你可以查詢所請求的相依屬性的識別碼,以判斷是否有更具體 PropertyType 的回傳值可以轉換成。

適用於

另請參閱