views:

311

answers:

2

Quick Explanation

One Silverlight (3.0) project with several XAML pages.

I want to load the Silverlight control pointing to different XAML pages depending on certain events. I'm considering doing this with Querystrings. Anyone have any luck with this or best practices?

+2  A: 

if you are not using prism/mvvm etc then just have a contentcontrol in the page and depending on what control you want to show, new-up that control and set the content of the ContentControl to the control you created

Can the content control show different XAMLS from the same silverlight project? I found a solution below but it may not be the best
Cody C
A: 

I found the answer to this. Actually pretty easy.

On web page, I pass in an ID using the initParameters.

Silverlight1.InitParameters = "ID=MAIN"

I then check for that parameter in the App.xaml in the SilverLight Project and load up the xaml accordingly

string inputparm = e.InitParams["ID"];
switch (inputparm)
    {
        case "MAIN":
            this.RootVisual = new MainPage();
            break;
        case "MAIN2":
            this.RootVisual = new MainPage();
            break;
    }
Cody C