This documentation is archived and is not being maintained.

FrameworkContentElement.FindName Method

Finds an element that has the provided identifier name.

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

public Object FindName (
	string name
)
public Object FindName (
	String name
)
public function FindName (
	name : String
) : Object
You cannot use methods in XAML.

Parameters

name

Name of the element to search for.

Return Value

The requested element. May be a null reference (Nothing in Visual Basic) 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.

void HighlightParagraph(string paraName)
{
    try
    {
        Paragraph wantedNode = (Paragraph)myflowdocument.FindName(paraName);
        if (wantedNode != null)
        {
            wantedNode.Background = Brushes.LightYellow;
        }
    }
    catch { }//handle paragraph not found in UI }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: