如何在Silverlight中设置“启动”页面? 不确定是否谷歌搜索错误的术语或它似乎没有在任何地方提到。
干杯
如何在Silverlight中设置“启动”页面? 不确定是否谷歌搜索错误的术语或它似乎没有在任何地方提到。
干杯
术语“启动页面”有点含糊不清。在Silverlight应用程序中,您可能意味着一些事情。
要作为RootVisual加载的初始UserControl
在app.xaml.cs中,您将找到如下代码: -
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
}
哪里 MainPage
是用户控件,它是初始根视觉。你可以改变这是你自己的选择。
也许你想要设置 RootVisual
选择其中一种可能的选择。在这种情况下,您需要使用 InitParams
。就像是:-
private void Application_Startup(object sender, StartupEventArgs e)
{
Type t = Type.GetType("SilverlightApplication1." + e.InitParams["StartupPage"]);
this.RootVisual = Activator.CreateInstance(t);
}
然后,您需要在中包含InitParams值 <object>
主机HTML中的标签: -
<object ...>
...
<param name="InitParams" value="StartupPage=Page1" />
</object
使用导航框架
如果您构建导航应用程序,则需要另一种方法。在这种情况下 MainPage
将包含一个 Frame
用一个 Source
包含要映射的初始URL的proeperty。
使用此类型的应用程序,您只需在页面的URL中添加#后面的路径即可指定要加载的备用页面。
术语“启动页面”有点含糊不清。在Silverlight应用程序中,您可能意味着一些事情。
要作为RootVisual加载的初始UserControl
在app.xaml.cs中,您将找到如下代码: -
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
}
哪里 MainPage
是用户控件,它是初始根视觉。你可以改变这是你自己的选择。
也许你想要设置 RootVisual
选择其中一种可能的选择。在这种情况下,您需要使用 InitParams
。就像是:-
private void Application_Startup(object sender, StartupEventArgs e)
{
Type t = Type.GetType("SilverlightApplication1." + e.InitParams["StartupPage"]);
this.RootVisual = Activator.CreateInstance(t);
}
然后,您需要在中包含InitParams值 <object>
主机HTML中的标签: -
<object ...>
...
<param name="InitParams" value="StartupPage=Page1" />
</object
使用导航框架
如果您构建导航应用程序,则需要另一种方法。在这种情况下 MainPage
将包含一个 Frame
用一个 Source
包含要映射的初始URL的proeperty。
使用此类型的应用程序,您只需在页面的URL中添加#后面的路径即可指定要加载的备用页面。