FrameworkContentElement.TemplatedParent Property
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.
Gets a reference to the template parent of this element. This property is not relevant if the element was not created through a template.
public:
property System::Windows::DependencyObject ^ TemplatedParent { System::Windows::DependencyObject ^ get(); };
public System.Windows.DependencyObject TemplatedParent { get; }
member this.TemplatedParent : System.Windows.DependencyObject
Public ReadOnly Property TemplatedParent As DependencyObject
Property Value
The element whose FrameworkTemplateVisualTree caused this element to be created. This value is frequently null
.
Remarks
Templates are actually shared objects, where the contents of the template are created only once. Therefore, if you obtain an object reference to an element that came from a template, you may find that the apparent logical tree does not reach to the page root. In order to connect such a template reference to the page's logical tree, you should get the TemplatedParent value and continue to navigate that element tree as desired.
TemplatedParent will frequently be null
for common objects, because if you have obtained an object reference from out of a page in your application through typical means, that element probably was not created from a template. Cases where TemplatedParent might not be null
would include operations such as hit-testing, event handling for certain low-level input events, or working with enumerators, which may have returned elements that came from templates.
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈