DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs) DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs) DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs) DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs) Method

定义

每当更新此 DependencyObject 的任何依赖属性的有效值时调用。Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. 更改的特定依赖项属性将在事件数据中报告。The specific dependency property that changed is reported in the event data.

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

参数

e
DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs

将包含相关依赖项属性标识符、类型的属性元数据以及旧值和新值的事件数据。Event data that will contain the dependency property identifier of interest, the property metadata for the type, and old and new values.

注解

此方法不是通常将检测到单个属性更改或在每个用例的基础上执行的属性失效。This method is not intended to generally detect individual property changes or perform invalidations of properties on a per-case basis. OnPropertyChanged 而被适用于修改常规失效模式中,如果特定的信息了解了宽分类的属性。OnPropertyChanged is instead intended for modifications of the general invalidation pattern, if certain information is known about wide classifications of properties. 例如中, 更改Freezable可能会发生更改的值类型Freezable,或者可能是子属性,其中所做的更改是在其他Freezable的引用。For example, changes in a Freezable might be changes in the value types of the Freezable, or might be subproperties, where the changes are within other Freezable references. Freezable重写实现OnPropertyChanged使用内部信息来确定属性是否为子属性,并为任一种情况下提供了相应的基类逻辑。The Freezable override implementation of OnPropertyChanged uses internal information to determine whether the properties are subproperties, and provides appropriate base class logic for either case.

OnPropertyChanged 一个对象的生命周期内可能调用多次。OnPropertyChanged is potentially invoked many times during the life of an object. 因此,可以实现更好的总体属性系统的性能,如果重写特定属性的元数据,然后将附加CoerceValueCallbackPropertyChangedCallback各个属性的函数。Therefore, you can achieve better performance for the overall property system if you override the metadata of specific properties and then attach CoerceValueCallback or PropertyChangedCallback functions for individual properties. 但是,应使用此方法,如果DependencyObject包括大量的值相关的依赖项属性,或如果它包含逻辑,例如呈现行为,必须重新运行多个相关的属性失效的情况。However, you would use this method if a DependencyObject 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.

继承者说明

始终调用基实现。Always call the base implementation. 如果不这样做将大大禁用整个WPFWPF属性系统,从而导致不正确的值报告。Failure to do this will significantly disable the entire WPFWPF property system, causing incorrect values to be reported.

适用于

另请参阅