FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs) 方法

定義

每當這個 FrameworkElement 上任何相依性屬性的有效值已更新時叫用。 已變更的特定相依性屬性會在引數參數中報告。 覆寫 OnPropertyChanged(DependencyPropertyChangedEventArgs)

protected:
 override void OnPropertyChanged(System::Windows::DependencyPropertyChangedEventArgs e);
protected override void OnPropertyChanged (System.Windows.DependencyPropertyChangedEventArgs e);
override this.OnPropertyChanged : System.Windows.DependencyPropertyChangedEventArgs -> unit
Protected Overrides Sub OnPropertyChanged (e As DependencyPropertyChangedEventArgs)

參數

e
DependencyPropertyChangedEventArgs

事件資料,描述已變更的屬性,以及舊值和新值。

備註

這個方法並非通常用來偵測屬性變更或失效。 如果已知有關各種屬性分類的特定資訊,則會改為修改一般失效模式。

這個方法可能會在物件存留期間多次叫用。 因此,如果您覆寫特定屬性的中繼資料,然後附加 CoerceValueCallbackPropertyChangedCallback 函式個別屬性,則可以達到更好的效能。 不過,如果 FrameworkElement 包含大量值相互關聯的相依性屬性,或包含必須針對數個屬性失效相關案例重新執行的轉譯行為之類的邏輯,您可以使用這個方法。

請注意,參數類型 (參數類型 PropertyChangedEventArgs 會顯示在數個類別上) 具有相同名稱 OnPropertyChanged 的方法。 這 OnPropertyChanged 用於資料物件通知,而且是 的 INotifyPropertyChanged 合約的一部分。

給繼承者的注意事項

一律呼叫基底實作,作為實作中的第一個作業。 若無法這麼做,將會大幅停用整個 WPF 屬性系統,這會導致報告不正確的值。 特定 FrameworkElement 實作也負責維護影響可見使用者介面的各種屬性的適當狀態。 這些包括根據適當時間變更樣式來使視覺化樹狀結構失效。

適用於

另請參閱