FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs) FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs) FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs) FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs) Method

定義

每當這個 FrameworkElement 上任何相依性屬性的有效值已更新時叫用。Invoked whenever the effective value of any dependency property on this FrameworkElement has been updated. 已變更的特定相依性屬性會在引數參數中報告。The specific dependency property that changed is reported in the arguments parameter. 覆寫 OnPropertyChanged(DependencyPropertyChangedEventArgs)Overrides 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 DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs

事件資料,描述已變更的屬性,以及舊值和新值。The event data that describes the property that changed, as well as old and new values.

備註

這個方法不是要用於偵測一般的屬性變更或失效。This method is not intended to generally detect property changes or invalidations. 它改為適用於一般失效模式修改如果已知廣泛分類屬性的特定資訊。It is instead intended for modifications of the general invalidation pattern if certain information is known about wide classifications of properties.

這個方法是可能被叫用次數物件的存留期間。This method is potentially invoked many times during the life of an object. 因此,達到更佳的效能,如果您覆寫特定屬性的中繼資料,然後將附加CoerceValueCallbackPropertyChangedCallback個別屬性的函式。Therefore, you can achieve better performance if you override the metadata of specific properties and then attach CoerceValueCallback or PropertyChangedCallback functions for individual properties. 不過,您會使用這個方法如果FrameworkElement包含大量的值相互關聯的相依性屬性,或者如果它包含邏輯,例如轉譯行為,必須重新執行的許多相關的屬性失效的情況。However, you would use this method if a FrameworkElement includes a significant number of value-interrelated dependency properties, or if it includes logic such as rendering behavior that must be rerun for several related cases of property invalidations.

請注意,有同名OnPropertyChanged方法具有不同的簽章 (參數類型是PropertyChangedEventArgs) 可以出現在數個類別上。Note that there is an identically named OnPropertyChanged method with a different signature (the parameter type is PropertyChangedEventArgs) that can appear on a number of classes. OnPropertyChanged用於資料物件的通知,而且是合約的一部分INotifyPropertyChangedThat OnPropertyChanged is used for data object notifications, and is part of the contract for INotifyPropertyChanged.

給繼承者的注意事項

務必呼叫基底實作中,在實作中的第一個作業。Always call the base implementation, as the first operation in your implementation. 如果沒有這樣做會大幅停用整個WPFWPF屬性系統中,這會導致報告不正確的值。Failure to do this will significantly disable the entire WPFWPF property system, which causes incorrect values to be reported. 特定FrameworkElement實作也會負責維護適當的狀態,針對各種會影響顯示的使用者介面的屬性。The specific FrameworkElement implementation is also responsible for maintaining proper state for a variety of properties that affect the visible user interface. 這些包括讓失效的變更樣式在適當的時間為基礎的視覺化樹狀結構。These include invalidating the visual tree based on changes to style at appropriate times.

適用於

另請參閱