如何从 xap 文件加载特定的 xaml 文件



我有以下页面引用了我的 silverlight 应用程序文件。 这工作正常。 我想知道是否可以指向 .xap 文件中的特定 xaml 文件?

也许像/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>

谢谢!

首先,请在此处查看我对一个非常相似的请求的回答,该请求可以满足您所需的大部分工作。

您现在需要的只是将 xaml 文件名从查询字符串获取到 initparams。 您现有的代码将变为:-

            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]%>'
        );

最新更新