2
votes

I have a hybrid javascript/Silverlight web app where I am using CreateFromXaml() to build a silverlight DOM from JS.

Now I am trying to instantiate a new Control that lives in an external XAP file (up to this point I haven't loaded any XAPs, just creating everything programmatically with JS). This XAP lives along side my app JS on the web server. How do I do this? Specifically, what should my XAML fragment look like such that I can reference (and download, if needed) an external XAP? Is this even possible?

Thanks in advance!

1

1 Answers

0
votes

Use the CreateFromXamlDownloader method:

// Create the event handler for the Completed event.
function onCompleted(sender, eventArgs)
    {
    // Retrieve a reference to the plug-in.
    var slPlugin = sender.getHost();

    // Retrieve the specified XAML file from the packaged downloader content,
    // and create an object reference.
    var xamlFragment = slPlugin.content.createFromXamlDownloader(sender, "OK_button.xaml");

    // Add the XAML object as a child of the root Canvas object.
    var root = sender.findName("rootCanvas");
    root.children.add(xamlFragment);
    }