FindName Method
Collapse the table of content
Expand the table of content

TextElement.FindName Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets an object in the Windows Phone object model by referencing the object's x:Name or Name attribute value.

Namespace:  System.Windows.Documents
Assembly:  System.Windows (in System.Windows.dll)

Public Function FindName ( _
	name As String _
) As Object


Type: System.String
The name of the object to retrieve.

Return Value

Type: System.Object
The object that has the specified name, or Nothing if no object is retrieved.

FrameworkElement is the class that implements Name support for most other Windows Phone objects, such as Canvas, but TextElement is not a FrameworkElement. Therefore TextElement supports its own Name and FindName implementations so that you can still retrieve XAML-instantiated instances of TextElement classes such as Run at run time, and you can arbitrarily call FindName again on any Windows Phone object you retrieved from calling FindName previously. You can use the TextElement-defined FindName to find a named element specified as a FrameworkElement Name,and vice versa. Because FindName relies on all XAML being parsed for the Name attributes, you should not attempt to call FindName until the XAML is loaded. There are limitations across XAML namescopes.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Windows Phone

© 2017 Microsoft