Skip to main content

Microsoft Silverlight

Answered Question How to use SL 1 in SL 2 applicationRSS Feed

(0)

silverbyte
silverbyte

Participant

Participant

1338 points

405 Posts

How to use SL 1 in SL 2 application

 Hello,

I have the application written in JavaScript in SL 1 and now I want to make the application accessible from a SL 2 application to enhace it (use the SL 2 controls)

I created a SL 2 application and I am trying to call an entry point function of SL 1 application JavaScript code:

I  need to pass plugin and rootelement but I don't know if it's possible.

I do this:

// Page.xaml.cs

    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }

        public void Run()
        {
            HtmlPage.Window.Invoke("createScene", HtmlPage.Plugin);  // i need to pass plugin and root element
        }
    }
 

in App.xaml.cs:

         private void Application_Startup(object sender, StartupEventArgs e)
        {
            Page page = new Page();
            this.RootVisual = page;
            page.Run();
        }

  in BLOCKED SCRIPT

function createScene(plugin, rootEleement)

{

  // run SL 1 code using plugin and rootElement
}

 

 How can I use SL 1 code in SL 2 application ?

I need to have only one Silverlight plugin in the page which content will be modified both from C# and JavaScript.

What I am thinking is to make the SL 2 application as the 'host' which creates the root element which SL 1 code will use.

Is it possible ?


 
Thank you.

 

Please click on 'Mark as answer' near my comment if you feel I answered your question.

Shaji-mji
Shaji-mji

Participant

Participant

1129 points

260 Posts

Re: How to use SL 1 in SL 2 application

SL1 will work with SL2 beta 2 plugin. So its possible to use the same code..

 

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Answered Question

Re: How to use SL 1 in SL 2 application

Hello, the programming model of SL1 and SL2 are completely different. There's no way to "enhance" an SL1 application with SL2 unless you completely discard the new programming model, and use the old XamlReader.Load way. You have the following options:

  • Leave the SL1 application as it is. It still functions properly.
  • Call Silverlight.createObject function in SL2 managed code to create an SL1 application.
  • Call a JavaScript function in SL2 managed code which will modify the SL1 content.
  • Don't use the SL2 programming model. That is, don't use UserControl + code behind, don't use data binding, DataTemplate. Use XamlReader.Load to load existing SL1 XAML pages.
  • Rewrite the SL1 application with SL2.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities