FrameworkContentElement.FindName Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Finds an element that has the provided identifier name.

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

Public Function FindName (
	name As String
) As Object


Type: System.String

Name of the element to search for.

Return Value

Type: System.Object

The requested element. May be null if no matching element was found.

If this element has child elements, these child elements are all searched recursively for the requested named element.

The following example sets a property on an element found by name within a referenced FlowDocument on a page.

Private Sub HighlightParagraph(ByVal paraName As String)
		Dim wantedNode As Paragraph = CType(myflowdocument.FindName(paraName), Paragraph)
		If wantedNode IsNot Nothing Then
			wantedNode.Background = Brushes.LightYellow
		End If
	Catch 'handle paragraph not found in UI }
	End Try
End Sub

.NET Framework
Available since 3.0
Return to top