Control.OnTemplateChanged(ControlTemplate, ControlTemplate) Control.OnTemplateChanged(ControlTemplate, ControlTemplate) Control.OnTemplateChanged(ControlTemplate, ControlTemplate) Control.OnTemplateChanged(ControlTemplate, ControlTemplate) Method

定义

在控件模板发生更改时调用。Called whenever the control's template changes.

protected:
 virtual void OnTemplateChanged(System::Windows::Controls::ControlTemplate ^ oldTemplate, System::Windows::Controls::ControlTemplate ^ newTemplate);
protected virtual void OnTemplateChanged (System.Windows.Controls.ControlTemplate oldTemplate, System.Windows.Controls.ControlTemplate newTemplate);
abstract member OnTemplateChanged : System.Windows.Controls.ControlTemplate * System.Windows.Controls.ControlTemplate -> unit
override this.OnTemplateChanged : System.Windows.Controls.ControlTemplate * System.Windows.Controls.ControlTemplate -> unit
Protected Overridable Sub OnTemplateChanged (oldTemplate As ControlTemplate, newTemplate As ControlTemplate)

参数

oldTemplate
ControlTemplate ControlTemplate ControlTemplate ControlTemplate

旧模板。The old template.

newTemplate
ControlTemplate ControlTemplate ControlTemplate ControlTemplate

新模板。The new template.

注解

更改模板的计时如下:The timing for changing the template is as follows:

  1. SetValue方法调用、样式触发器或其他一些方法会更改模板。The template is changed by a SetValue method call, a style trigger, or some other means.

  2. 属性值更改;将调用属性更改的回调。The property value changes; the property-changed callback is called.

  3. 旧的可视化树将被删除。The old visual tree is removed.

  4. 调用的内部方法最终将调用OnTemplateChanged方法。An internal method is called which eventually calls the OnTemplateChanged method.

  5. 稍后, 在度量值OnApplyTemplate过程中, 将调用并附加新的可视化树。Later, during a measure, OnApplyTemplate is called and a new visual tree is attached.

适用于