如何将siilverlight与Web集成在一起

问题描述

| 通过提供具有正确值的source参数,我可以将silverlight xap文件集成到网站页面中。就像是:
<object data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\"100%\" height=\"100%\">
          <param name=\"source\" value=\"ClientBin/Demo3.xap\"/>
          <param name=\"onError\" value=\"onSilverlightError\" />
          <param name=\"background\" value=\"white\" />
          <param name=\"minRuntimeVersion\" value=\"4.0.50826.0\" />
          <param name=\"uiculture\" value=\"<%= System.Threading.Thread.CurrentThread.CurrentUICulture %>\" />
          <param name=\"culture\" value=\"<%= System.Threading.Thread.CurrentThread.CurrentCulture %>\" />
          <param name=\"autoUpgrade\" value=\"true\" />
          <a href=\"http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0\" style=\"text-decoration:none\">
              <img src=\"http://go.microsoft.com/fwlink/?LinkId=161376\" alt=\"Get Microsoft Silverlight\" style=\"border-style:none\"/>
          </a>
        </object>
但是,问题是我的Silverlight项目有多个页面,我想分别显示在站点的不同网页上。 查询:如何修改源param标签以加载特定的xaml页面? 如果这不可能,那么如何实现这一目标呢?     

解决方法

        StartupEventArgs.InitParams属性 Silverlight处理程序:
private void Application_Startup(object sender,StartupEventArgs e)
{
    // look into e.InitParams property and let\'s say we can get the following variable:
    bool showPage1;

    // let\'s say we have two pages - Page1.xaml and Page2.xaml
    RootVisual = showPage1 ? (UIElement) new Page1() : new Page2();
}
html(请参阅initParams):
<object id=\"slPlugin1\" width=\"300\" height=\"50\"
        data=\"data:application/x-silverlight-2,\" 
        type=\"application/x-silverlight-2\" >
        <param name=\"source\" value=\"ClientBin/SilverlightApplication.xap\"/>
        <param name=\"initParams\"
            value=\"id=slPlugin1,embeddingTechnique=objectElement\"/>
        <!-- Installation HTML omitted. -->
    </object>    
    

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...