Silverlight template support is not fully enabled on FrameworkElement. Instead, Silverlight provides template support for Control, which is an immediate subclass of FrameworkElement, as well as a specialized template behavior for ContentPresenter. OnApplyTemplate is defined at the FrameworkElement level for WPF compatibility reasons.
Notes to Inheritors: This method potentially has a native implementation (which is referenced by the default implementation), so you should always call the base implementation.
Derived classes can use this method as a notification/entry point to:
Build the remainder of a 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. However, note that a well-designed control should generally handle its visual and behavioral states through VisualStateManager. For details on this concept, see Control Customization.
OnApplyTemplate is a more appropriate point to deal with adjustments to the template-created visual tree than is the Loaded event. In Silverlight, the Loaded event might occur before the template is applied, and thus you might not be able to adjust the visual tree that is created through the template in a Loaded handler. For more information, see the Remarks for Loaded.