Silverlight深度链接不使用页面和框架?
我需要能够使用 Silverlight 模块加载 html 页面,该模块显示基于访问页面的内容。例如,如果打开页面的请求来自Page1.html,则内容将显示Content.1。我试图解决这个问题,但需要更多信息。非常感谢任何帮助:
这是我的代码: HTML:分配新参数:
<param name="inputParams" value="Page1.html" />
它可以是不同的 url 字符串。
中的 Silverlight 代码
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
if (e.InitParams != null)
{
string ValueParam = e.InitParams["value"];
}
}
App.xaml.cs MainPage.xaml.cs
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
if (ValueParam = ?)
{
contentIndex =1;
}
}
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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
initParams
参数的值本身应该是一系列逗号分隔的 name=value 对。您的 param 元素应如下所示:-
说了您的具体要求后,您可以通过
HtmlPage
对象访问主机页面的 URL。这可以让您不必专门将页面名称复制到每个页面的每个 initParams 中。
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:-
Having said that your specific requirement you can the at the host page's URL via the
HtmlPage
object.This can save you having to specifically copy the page name into each initParams for each page.