Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
OnTemplateChanged Method

Control.OnTemplateChanged Method

Called whenever the control's template changes.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)

Protected Overridable Sub OnTemplateChanged ( _
	oldTemplate As ControlTemplate, _
	newTemplate As ControlTemplate _
Dim oldTemplate As ControlTemplate
Dim newTemplate As ControlTemplate

Me.OnTemplateChanged(oldTemplate, newTemplate)
protected void OnTemplateChanged (
	ControlTemplate oldTemplate, 
	ControlTemplate newTemplate
protected function OnTemplateChanged (
	oldTemplate : ControlTemplate, 
	newTemplate : ControlTemplate
You cannot use methods in XAML.



The old template.


The new template.

Return Value

A template.

The timing for changing the template is as follows:

  1. Somehow the template is changed, for example, by SetValue or a style trigger.

  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 OnTemplateChanged.

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

© 2015 Microsoft