Control.OnTemplateChanged(ControlTemplate, ControlTemplate) 方法
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
每當控制項的範本變更時呼叫。
protected:
virtual void OnTemplateChanged(System::Windows::Controls::ControlTemplate ^ oldTemplate, System::Windows::Controls::ControlTemplate ^ newTemplate);
C#
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
舊的範本。
- newTemplate
- ControlTemplate
新的範本。
變更範本的時機如下:
範本會由 SetValue 方法呼叫、樣式觸發程式或其他方法變更。
屬性值會變更;呼叫屬性變更的回呼。
已移除舊的視覺化樹狀結構。
呼叫內部方法,最後會呼叫 OnTemplateChanged 方法。
稍後會在量值期間呼叫 , OnApplyTemplate 並附加新的視覺化樹狀結構。
產品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |