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.

適用於