2010-12-07 42 views
2

我有一個混合的JavaScript/Silverlight的web應用程序在那裏我使用CreateFromXaml()來構建從JS一個Silverlight DOM。Silverlight JS API - 按需加載XAP?

現在我試圖實例,生活在一個外部XAP文件(到現在爲止我還沒有裝任何XAPs,只需用JS創造一切編程)的新控制。這個XAP與我的應用程序JS在Web服務器上一起生活。我該怎麼做呢?具體來說,我的XAML片段應該是什麼樣的,以便我可以引用(並在需要時下載)外部XAP?這甚至有可能嗎?

在此先感謝!

回答

0

使用CreateFromXamlDownloader方法:

// 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); 
    }