CreateFromXaml has an important XAML namescope behavior difference as compared to the managed XamlReader.Load. Using the default (one-parameter) signature of CreateFromXaml, a preliminary XAML namescope is created, based on the root of the provided XAML. This preliminary XAML namescope evaluates any defined names in the provided XAML for uniqueness. If names in the provided XAML are not internally unique at this point, CreateFromXaml throws an error. If names in the provided XAML collide with names that are already in the primary Silverlight namescope, no errors occur immediately. When the CreateFromXaml method is called, the created object tree that is returned is disconnected. As with the managed XamlReader.Load usage, you must explicitly connect your created object tree, either by adding it to a content property collection such as Canvas.Children or by setting some other property that takes an object value (such as specifying a new ImageBrush for a Fill property value).
Walk the entire tree in discrete steps with GetParent and/or collection properties.
If you are calling from a discrete XAML namescope and want the main application namescope, you can get a reference to the Silverlight plug-in and then call FindName on it. The concatenated script call for doing this in a single line is as follows:
returnedObject = object .GetHost().content.FindName(" nameToFind ");
where object is the calling object in a discrete XAML namescope. The .content in this syntax is the step through to the specific Silverlight plug-in sub-object that defines the FindName method.
If you are calling from the main application XAML namescope and want an object within a discrete XAML namescope, the best thing to do is to plan ahead in your code and retain a reference to the object that was returned by CreateFromXaml and then added to the object tree. This object is now a valid object for calling FindName within the created discrete XAML namescope.
The FindName method defined on the Silverlight plug-in object does not entirely work around the disconnected XAML namescope problems of CreateFromXaml described in this topic; its XAML namescope is always the root XAML namescope.