I have read Silverlight unleashed and know that Silverlight. Createobject and Silverlight. createobjectex functions are available in Silverlight. js. When using these two functions instead of static <Object> labels, You can dynamically load different xap packages (different Silverlight applicationsProgram).
Create two Silverlight applications and a web application. The solution looks like this:
The two Silverlight applications are common, but the two xap packages under the clientbin directory of the Web application are the compiled Silverlight applications. In Web applications, Silverlight. JS is generated by vs. The Silverlight. Createobject and Silverlight. createobjectex functions are in it. First, create the silverlightlibrary. js file and add the commonly used onsilverlighterror function.
On the default aspx or HTML test page, this function is set in <Object> <param>. Now, it will be set in JavaScript.
Next, add the createsilverlight function to the silverlightlibrary. js file. This function is an encapsulation of Silverlight. createobjectex. Most of the parameter settings in this function correspond to <param> of <Object>. Source is passed in by parameters. parentelement is set to a <div> (placeholder) on the page, and background in properties is set to the background color controlled by CSS, onerror is set to the previous onsilverlighterror function.
Create the createsilverlightbyjs.htm file, and add two single-choice buttons, one button, and one seat <div> (placeholder) in the <body> area ). The Value Attribute of the single-choice button is set to the name of the xap package, and The onclick attribute of the button is set to the create function that will be added later.
In the
Running status:
That's all. Enjoy!