FrameworkContentElement.OnPropertyChanged(DependencyPropertyChangedEventArgs) 方法

定义

每当更新此 FrameworkContentElement 的任何依赖属性的有效值时调用。Invoked whenever the effective value of any dependency property on this FrameworkContentElement 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);
abstract member OnPropertyChanged : System.Windows.DependencyPropertyChangedEventArgs -> unit
override this.OnPropertyChanged : System.Windows.DependencyPropertyChangedEventArgs -> unit
override this.OnPropertyChanged : System.Windows.DependencyPropertyChangedEventArgs -> unit
Protected Overrides Sub OnPropertyChanged (e As DependencyPropertyChangedEventArgs)

参数

e
DependencyPropertyChangedEventArgs

描述已更改的属性的事件数据,包括旧值和新值。The event data that describes the property that changed, including the 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. 因此,如果你重写特定属性的元数据,然后 CoerceValueCallback 为单个属性附加或函数,则可以获得更好 PropertyChangedCallback 的性能。Therefore, you can achieve better performance if you override the metadata of specific properties and then attach CoerceValueCallback or PropertyChangedCallback functions for individual properties. 但是,如果 FrameworkContentElement 包含大量与值相关的依赖项属性,则可以使用此方法,或者,如果包含的逻辑(如呈现行为)必须针对属性失效的几个相关事例重新运行,则应使用此方法。However, you would use this method if a FrameworkContentElement 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.

适用于

另请参阅