Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Control.ApplyTemplate Method

Silverlight

Loads the relevant control template so that its parts can be referenced.

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

public bool ApplyTemplate()

Return Value

Type: System.Boolean
Returns whether the visual tree was rebuilt by this call. true indicates the tree was rebuilt; false indicates that the previous visual tree was retained.

For typical element logic within applications, such as when consuming existing controls, calling ApplyTemplate is not necessary, because templates will be applied to elements at an appropriate point in their lifetimes automatically. ApplyTemplate is generally speaking used only by authors of controls.

Call this method for cases where a control is the parent of another templated control, and the child control template must exist so that the parent control can apply all necessary state and run-time property setting in the parent's instantiation logic.

Any layout pass that generates a new layout will also call ApplyTemplate on a control.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft