PropertyMetadata.PropertyChangedCallback PropertyMetadata.PropertyChangedCallback PropertyMetadata.PropertyChangedCallback PropertyMetadata.PropertyChangedCallback Property


获取或设置对此元数据中所指定 PropertyChangedCallback 实现的引用。Gets or sets a reference to a PropertyChangedCallback implementation specified in this metadata.

 property System::Windows::PropertyChangedCallback ^ PropertyChangedCallback { System::Windows::PropertyChangedCallback ^ get(); void set(System::Windows::PropertyChangedCallback ^ value); };
public System.Windows.PropertyChangedCallback PropertyChangedCallback { get; set; }
member this.PropertyChangedCallback : System.Windows.PropertyChangedCallback with get, set
Public Property PropertyChangedCallback As PropertyChangedCallback



将元数据属性应用于依赖属性操作后,无法设置该属性。Cannot set a metadata property once it is applied to a dependency property operation.


属性元数据中的回调通常不是定义类型上的公共成员, 因此, 此属性的值对于只使用现有依赖属性的元数据的大多数方案并不重要。The callbacks in property metadata are not typically public members on the defining type, so the value of this property is not important for most scenarios that just consume an existing dependency property's metadata. 此属性被公开的一个原因是, 如果基本元数据和重写/添加元数据都指定PropertyChangedCallback, 则元数据类可以执行其所需的合并逻辑。One reason this property is exposed is so that metadata classes can perform their desired merge logic if both base metadata and overriding/adding metadata specify a PropertyChangedCallback. 的默认合并逻辑是维护表中的PropertyChangedCallback所有实现, 并通过在层次结构中第一个运行的最深层类建立回调来调用每个实现。The default merge logic for is to maintain all PropertyChangedCallback implementations in a table and call each of them, with callbacks established by the deepest class in hierarchy running first.

PropertyChangedCallback在对象模型中定义为读写。PropertyChangedCallback is defined in the object model as read-write. 这样PropertyChangedCallback就可以在PropertyMetadata对象本身初始化后进行调整。This is so PropertyChangedCallback can be adjusted after initialization of the PropertyMetadata object itself. 但是, 在调用RegisterAddOwnerOverrideMetadata的过程中使用元数据后, 属性系统将密封该元数据实例, 并且属性现在被视为不可变。However, once the metadata is consumed as part of a call to Register, AddOwner, or OverrideMetadata, the property system will seal that metadata instance and the properties are now considered immutable. 如果尝试设置PropertyChangedCallbackIsSealedtrue , 此元数据实例将引发异常。Attempting to set PropertyChangedCallback once IsSealed is true on this metadata instance will raise an exception.