Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

FindName Method (Silverlight Plug-in)

Gets any object in the Silverlight object hierarchy by referencing the object's x:Name or Name attribute value.

XAML
Cannot use methods in XAML.
Scripting
retval = silverlightObject.content.FindName(objectName)

Parameters

objectName

string

The name of the object to get.

Return Value

object

A reference to the specified object if the object was successfully found; otherwise, returns null.

Remarks

This method is available on the content sub-object of a Silverlight plug-in instance.

You can find any object in the Silverlight object hierarchy by using the FindName method of the Silverlight plug-in and referencing the object's x:Name or Name attribute value. This object you are searching for can be any named object in the Silverlight object hierarchy. If the FindName method is successful, a reference to the object is returned; otherwise, null is returned.

For more information on accessing Silverlight controls, see Referencing and Modifying Silverlight Objects.

Examples

The following JavaScript example shows how use the FindName method:

JavaScript
function onLoaded(sender, eventArgs)
{
    // Retrieve a reference to the plug-in.
    var slPlugin = sender.getHost();

    // Retrieve a reference to the specified object.
    var object = slPlugin.content.findName("myTextBlock");

    // If a valid object reference, display an alert dialog box.
    if (object != null)
    {
        alert(object.toString() + " found");
    }
}

Applies To

Silverlight Plug-in

See Also

Silverlight Object Models and Scripting to the Silverlight Plug-in
Referencing and Modifying Silverlight Objects

Community Additions

Show:
© 2015 Microsoft