vladc77
vladc77

Reputation: 1064

Silverlight deep linking not using pages and frame?

I need to be able to load html page with Silverlight module presenting the content based on page was accessed from. For example, if request to open the page come from Page1.html than the content will show Content.1. I tried to work on it but need more information. Any help is highly appreciated:

Here is my code: HTML: assigned new param:

<param name="inputParams" value="Page1.html" /> 

It can be a different url string.

Silverlight Code in App.xaml.cs

private void Application_Startup(object sender, StartupEventArgs e)
    {
        this.RootVisual = new MainPage();
        if (e.InitParams != null)
        {
            string ValueParam = e.InitParams["value"];
        }
    }

MainPage.xaml.cs

public MainPage() 
    { 
        InitializeComponent(); 

        this.Loaded += new RoutedEventHandler(MainPage_Loaded);  

    } 

    void MainPage_Loaded(object sender, RoutedEventArgs e) 
    { 
        if (ValueParam = ?) 
        { 
            contentIndex =1; 
        } 
    } 

Upvotes: 2

Views: 132

Answers (1)

AnthonyWJones
AnthonyWJones

Reputation: 189505

The value of the initParams parameter is itself expected to be a series comma separated of name=value pairs.

Your param element should look like this:-

 <param name="inputParams" value="value=Page1.html" />

Having said that your specific requirement you can the at the host page's URL via the HtmlPage object.

 string path = HtmlPage.Document.DocumentUri.AbsolutePath;

This can save you having to specifically copy the page name into each initParams for each page.

Upvotes: 2

Related Questions