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.GetTemplateChild method

Applies to Windows and Windows Phone

Retrieves the named element in the instantiated ControlTemplate visual tree.

Syntax


protected DependencyObject GetTemplateChild(
  string childName
)

Parameters

childName

Type: System.String [.NET] | Platform::String [C++]

The name of the element to find.

Return value

Type: DependencyObject

The named element from the template, if the element is found. Can return null if no element with name childName was found in the template.

Remarks

You call GetTemplateChild to get references to objects in a controls Template after it's instantiated. The ControlTemplate is instantiated in the OnApplyTemplate method. You can use the GetTemplateChild method inside your OnApplyTemplate override and keep a reference to the objects you need.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

Control
OnApplyTemplate

 

 

Show:
© 2014 Microsoft