开发者

Silverlight deep linking not using pages and frame?

开发者 https://www.devze.com 2023-03-16 05:46 出处:网络
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

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()开发者_StackOverflow社区;
        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; 
        } 
    } 


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号