When your Silverlight control loads, it loads up some XAML. It's most likely that this comes from a file specified by the source parameter. For instance;
function createSilverlight()
{
Sys.Silverlight.createObjectEx({
source: "Page1.xaml",
parentElement: document.getElementById("SilverlightControlHost"),
id: "SilverlightControl",
properties: {
width: "100%",
height: "100%",
version: "0.95",
enableHtmlAccess: true
},
events: {}
});
}
It might be that at some later point you want to switch from Page1.xaml to Page2.xaml in order to avoid having to put everything into a single XAML file.
You can do this but (I'm very reliably informed) not from managed code right now and, furthermore, you can't even initiate the sequence from managed code. If you try it from managed code (using the HtmlObject object) then you'll get an error saying something like "No, you can't do that right now".
So, you need to do it from Javascript and just change the source property;
function OnChangePage()
{
document.getElementById('SilverlightControl').source = "Page2.xaml";
}
what did I mean by "initiate the sequence from managed code" - you need to make sure that the page switch comes from a "purely" Javascript place. That is, if your Javascript function to switch pages is called as a result of an event in the managed world then it'll fail (crash is what I'm told).
In my case, I wanted to change pages when an animation completed so that was a scenario where it was easy enough to add a purely Javascript handler to and perform the page-switch there.
Posted
Wed, Jul 25 2007 5:18 PM
by
mtaulty