Control.OnTemplateChanged(ControlTemplate, ControlTemplate) Method

Definition

Called whenever the control's template changes.

C#
protected virtual void OnTemplateChanged(System.Windows.Controls.ControlTemplate oldTemplate, System.Windows.Controls.ControlTemplate newTemplate);

Parameters

oldTemplate
ControlTemplate

The old template.

newTemplate
ControlTemplate

The new template.

Remarks

The timing for changing the template is as follows:

  1. 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. An internal method is called which eventually calls the OnTemplateChanged method.

  5. Later, during a measure, OnApplyTemplate is called and a new visual tree is attached.

Applies to

Product Versions
.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