Archive for November, 2007

How to load multiple silverlight elements on one page?

Hi all. Recently I have started learning and working silverlight. Here I am not explaining what it is as this you might get anywhere. Anyway’s lets consider that we know how to load silverlight element on page, but what if I want to load more then one. Here it is how.

We must be knowing that there is a respective file for its html file named TestPage.html.js in which there is a method called “createSilverlight”. I have just renamed it to “createSilverlightEx”. Now to load silverlight element it needs one xaml page, a parentid where it needs to load and one elementid which is a unique id for all loaded silverlight controls.

Besides writing method “createSilverlight” again and again to create various silverlight elements, just have 3 params in “createSilverlightEx” method. Hence it will create controls as many depends on params.

function createSilverlightEx(xamlFile, parentID, elemID)

{
    Silverlight.createObjectEx({
        source: xamlFile, // 1st PARAM
        parentElement: document.getElementById(parentID), // 2nd PARAM
        id: elemID, // 3rd PARAM
        properties: {
            width: “700″,
            height: “150″,
            version: “1.1″,
            enableHtmlAccess: “true”
        },
        events: {}
    });

}

Leave a Comment