如何从XAP文件加载特定的XAML文件? [英] How to load specific xaml file from a xap file?
问题描述
我有以下页面引用我的Silverlight应用程序文件。这工作得很好。我在想,如果,相反,我可以指向一个特定的XAML文件是在.xap文件?
I have the following page that references my silverlight application file. This works fine. I was wondering if, instead, I could point to a specific xaml file that is in the .xap file?
也许类似 /ClientBin/test.xap?File=SomeXaml.xaml
?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test.Web.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Silverlight.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div id="silverlightControlHost">
<script type="text/javascript">
Silverlight.createObject(
"ClientBin/test.xap", // source
document.getElementById('silverlightControlHost'), // parent element
"someId", // id for generated object element
{
width: "600px",
height: "600px",
background: "blue",
version: "4.0.60310.0",
autoUpgrade: "true"
},
{ onError: null }, null
);
</script>
</div>
</form>
</body>
</html>
谢谢!
推荐答案
首先看我的答案<一个href=\"http://stackoverflow.com/questions/4123917/set-the-silverlight-start-page/4124109#4124109\">here到那你最需要什么。
First of all see my answer here to a very similar request that does most of what you need.
你现在需要的是从查询字符串到initParams在获得XAML文件名。您现有的code将成为: -
All you now need is to get the xaml file name from the query string to the initparams. Your existing code would become:-
Silverlight.createObject(
"ClientBin/test.xap", // source
document.getElementById('silverlightControlHost'), // parent element
"someId", // id for generated object element
{
width: "600px",
height: "600px",
background: "blue",
version: "4.0.60310.0",
autoUpgrade: "true"
},
{ onError: null }, 'StartupPage=<%=Request.QueryString[File]%>'
);
这篇关于如何从XAP文件加载特定的XAML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!