0

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?

CCovey
  • 799
  • 1
  • 10
  • 17
Cody C
  • 4,757
  • 3
  • 29
  • 36
  • Not sure what Querystrings are but this is super simple - just new 'em up like the below answer suggests. Same thing you could do back in the WinForms days. – James Cadd Jul 01 '09 at 02:12

2 Answers2

2

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

user122069
  • 419
  • 2
  • 3
  • 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 Jul 07 '09 at 03:14
0

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
  • 4,757
  • 3
  • 29
  • 36