FrameworkElement.OnApplyTemplate Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate().
public:
virtual void OnApplyTemplate();
public virtual void OnApplyTemplate ();
abstract member OnApplyTemplate : unit -> unit
override this.OnApplyTemplate : unit -> unit
Public Overridable Sub OnApplyTemplate ()
Remarks
This method has no default implementation.
Templates are the section of an element's completed visual tree that comes from the Template property of a Style that is applied for the element. For more information, see Styling and Templating.
Notes to Inheritors
Derived classes of FrameworkElement can use this method as a notification for a variety of possible scenarios:
You can call your own implementation of code that builds the remainder of an element visual tree.
You can 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.
You can introduce services that only make sense to exist after the visual tree from templates is complete.
You can 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.
Implementers should always call the base implementation before their own implementation. FrameworkElement itself has no default implementation, but intervening classes might.
Control offers a similar override, OnTemplateChanged(ControlTemplate, ControlTemplate).
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기