silverlight不能象flash一样,直接以类似xxx.xap?name=123的方式传递参数,而是要用另一种方式实现:
html部分(注意高亮部分):
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/InitParams.xap?color=red"/>
<param name="onerror" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<param name="InitParams" value="name=jimmy.yang,age=30" />
<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="获取 Microsoft Silverlight" style="border-style: none"/>
</a>
</object>
注:InitParams传递参数时,必须以x=y,a=b这样的键值对格式传入
cs部分:
App.Xaml.cs:
public partial class App : Application
{
IDictionary<string, string> _dic;
...
private void Application_Startup(object sender, StartupEventArgs e)
{
_dic = e.InitParams;
this.RootVisual = new MainPage(_dic);
}
...
注:这里用e.InitParams取得传入的参数,同时利用new MainPage(_dic)将参数传到需要的xaml中去
MainPage.Xaml.cs部分:
public partial class MainPage : UserControl
{
IDictionary<string, string> _params;
public MainPage()
{
InitializeComponent();
}
public MainPage(IDictionary<string, string> dicParam)
{
InitializeComponent();
_params = dicParam;
StringBuilder sb = new StringBuilder();
foreach (var item in _params)
{
sb.Append(string.Format("key:{0} , value:{1}" + Environment.NewLine, item.Key, item.Value));
}
txtParam.Text = sb.ToString();
}
}
注:这里,我们重载了一个带参数的构造函数用于接受参数
更简单方法:
1)aspx端
Response.Redirect("SLInterestTestPage.aspx?A=123&B=345");
2)Silverlight端接收
IDictionary<String, String> paras = HtmlPage.Document.QueryString;
string s = paras["A"];
string b = paras["B"];
注意:有时传递汉语会遇到乱码问题,解决方法是:把汉字进行Base64编码,接收时解码就不会有乱码问题了。
相关推荐
clientBin silverlight xap文件
介绍Silverlight与wcf异步调用,修改xap文件内的配置。内附源代码实例。
国外著名Silverlight网站相应的XAP文件,效果十分绚丽,可以用作参考素材。
JRTPLIB is an object-oriented RTP library written in C++. The library offers support for the Real-time Transport Protocol (RTP), defined in RFC 3550.
1.在现有SLLoader.xap项目中使用SilverlightLoader:先下载SilverlightLoader压缩包,从下载的Release中找到SilverlightLoader.cs,并将其添加到SLLoader.xap项目中,具体实现方法:在SLLoader.xap项目中右键添加已...
SiverlightAppDemo 入门 我上课做的练习。 适合初学者 参考 。
该项目旨在为开发人员提供一种简便的方法,使其可以在运行时动态下载XAP。 需要使用一个简单的界面,然后可以按需或提前下载XAP。
ppt转xap工具,ppt转xap工具,ppt转xap工具,ppt转xap工具
动态加载外部xap silverlight,这样通过映射和服务
SilverLight 幻灯效果xap包
xap软件.zip
jQuery的Silverlight插件,以jQuery的方式创建SL. $(function() { $("#silverlightControlHost").silverlight({ source: 'ClientBin/SilverlightApplication1.xap', height: '100%' }); });
XAP安装软件,玩转WP7手机 ,XAP安装软件,玩转WP7手机XAP安装软件,玩转WP7手机XAP安装软件,玩转WP7手机
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/mpost.SilverlightMultiFileUpload.xap" MinimumVersion="2.0.30523" Width="415" Height="280" InitParameters ="MaxFileSizeKB=1000,MaxUploads=...
XAP包(注:XAP文件是Silverlight 2应用程序编译打包后的一个文件,包括了Silverlight 2应用程序所需的一切文件,如程序集、资源文件等) 查看和导出XAP包内容; 查看和导出程序集和资源文件; 查看.NET类型和...
XAP 1.6
* Convert your SWF file to ready-to-run Silverlight application (or Silverlight XAP file) * Convert or import your Flash file into Silverlight, Windows Presentation Foundation (WPF) or Silverlight ...
可在桌面直接运行XAP文件 无需IE或VS编译环境 亲测好用
比以前的Tom XAP Installer 有很大改善,不用再启动Application Deployment安装了。 连接手机与电脑后,保持Zune运行。 以管理员身份运行Tom XAP Installer,然后选择设备类型,再选择要安装的xap程序,保持手机在...
XAP 400中文说明书,数字会议系统,数字调音系统