Control.OnApplyTemplate Method

When overridden in a derived class, is invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate.

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

Syntax

'Declaration
Public Overridable Sub OnApplyTemplate
'Usage
Dim instance As Control

instance.OnApplyTemplate()
public virtual void OnApplyTemplate()
public:
virtual void OnApplyTemplate()
public function OnApplyTemplate()

Remarks

Notes to Implementers:

This method has no default implementation.

Derived classes can use this method as a notification to:

  • Builds the remainder of an element visual tree using custom code.

  • Run code that relies on the visual tree from templates having been applied, such as obtaining references to named elements that came from a template.

  • Introduce services that only make sense to exist after the visual tree from templates is complete.

  • Set states and properties of elements within the template that are dependent on other factors. For instance, property values might only be discoverable by knowing the parent element, or when a specific derived class uses a common template.

See Also

Reference

Control Class

Control Members

System.Windows.Controls Namespace