Share via


TextElement.FindName(String) Method

Definition

Retrieves an object in the object model / runtime object graph by referencing the object's x:Name or Name attribute value.

public:
 virtual Platform::Object ^ FindName(Platform::String ^ name) = FindName;
IInspectable FindName(winrt::hstring const& name);
public object FindName(string name);
function findName(name)
Public Function FindName (name As String) As Object

Parameters

name
String

Platform::String

winrt::hstring

The name of the object to retrieve.

Returns

Object

Platform::Object

IInspectable

The object that has the specified name, or null if no object is retrieved.

Remarks

FrameworkElement is the class that implements Name support for most other run-time classes, but TextElement is not a FrameworkElement derived class. TextElement supports its own Name and FindName implementations, and the underlying logic for name lookup does not differentiate between TextElement and FrameworkElement. You can use the TextElement-implemented FindName to find a named FrameworkElement, and vice versa.

Because FindName relies on all the XAML sources being parsed for the Name attributes, you should not attempt to call FindName until the XAML is loaded.

Names and FindName are influenced by the concept of a XAML namescope.

Applies to