Silverlight asp:silverlight 标签
我是银光新手。对不起,如果这是一个简单的问题。
我正在尝试在 VS2010 中使用 Silverlight 4 创建一个示例应用程序。 aspx页面中default生成的代码是(除了脚本):
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/test.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
</div>
我想使用asp:silverlight标签,所以我添加了dll System.Web.Silverlight.dll (v2.0)。
我得到了标签,并将上面的代码替换为:
<asp:ScriptManager ID="ScriptManager1" runat="server" ></asp:ScriptManager>
<asp1:Silverlight ID="test" runat = "server" Source="~/ClientBin/test.xap">
</asp1:Silverlight>
现在上面的代码(自行生成的代码)可以工作,但是 asp:silverlight
显示空白屏幕。
另外,另一个问题,如果我们有2个或更多xaml文件,如何调用它们? (因为我们只是引用一个 xap 文件,所以在哪里提及程序应该引用哪个 xaml 文件)
提前致谢。
I am new to silverlight. Excuse me if this is simple question.
I am trying to craete a sample application using Silverlight 4 in VS2010. The code that is generated by defualt in the aspx page is(apart from the script):
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/test.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
</div>
I wanted to use asp:silverlight tag, so I added the dll System.Web.Silverlight.dll (v2.0).
I got the tag and I replaced the above code to:
<asp:ScriptManager ID="ScriptManager1" runat="server" ></asp:ScriptManager>
<asp1:Silverlight ID="test" runat = "server" Source="~/ClientBin/test.xap">
</asp1:Silverlight>
Now the above code (self generated one) works, however the asp:silverlight
shows blank screen.
Also, another questions, If we have 2 or more xaml files, how to call them?? (As we jsut refer to one xap file, where to mention which xaml file should the program refer)
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为 asp:Silverlight 标签已被废弃,我会使用生成的标签。对于其他 xaml 文件,您必须以某种方式将它们包含在 MainPage.xaml 中,方法是导航到它们或显示它们。
I think the asp:Silverlight tag is depricated, I'd go with the generated one. for the other xaml files, you have to include them in your MainPage.xaml somehow, either by navigating to them or showing them.
坚持使用
为了在 SL 应用程序内显示特定的 xaml 页面,我将假设显示哪个页面的选择是由应用程序外部发生的操作决定的。在这种情况下,有多种选择。您可以使用 javascript 调用 SL 应用程序中的托管代码函数,该函数可以显示相应的页面。您可以从 SL 应用程序调用回包含的页面 - 您可以调用 JavaScript 函数或访问页面上的 HTML 元素。或者,您可以将信息作为 SL 应用
InitParams
的一部分传递:在 aspx 页面的代码后面:
这些 InitParams 可用作
Application_Startup
中的StartupEventArgs
SL 应用程序的代码>:Stick with the
<object>
tag to define your Silverlight application, as @Alex mentions the old Silverlight server control is deprecated - all it does is render out theobject
tag for you and may not declare all the parameters you need. When using it, do a right click->view source on the rendered page and see what the differences are between it and using theobject
tag manually.For showing a specific xaml page inside the SL application, i am going to assume that the choice of which page to show is dictated by actions that happen outside of the app. In this case there are several options. You can use javascript to call a managed code function in the SL app and that function can show the appropriate page. You can call from the SL app back to the containing page - you can call a javascript function or access an HTML element on the page. Alternatively you could pass in the info as part of the SL app
InitParams
:in the aspx page's code behind:
these InitParams are available as your
StartupEventArgs
inApplication_Startup
of the SL app: