Passing initParams

Apr 16, 2009 at 8:19 AM
Hello,

Is there a possibility to pass initParams from the preloader xap to the final xap?
In the current version the initParams are translated to a package list which will be downloaded.
I did set the package list manually, but I want to add initParams to the xap.

Regards,
Arjan
Coordinator
Apr 23, 2009 at 9:32 AM
Edited Apr 23, 2009 at 9:37 AM

Hi Arjan,

Yes, there are 2 ways you can pass initParams to the loaded/final XAP:

1. Add a value in the loader initParams as an extra parameter separated by comma.

  Example:

  InitParams="LoaderSourceList=ClientBin/Target.xap,testValue=123"

2. Set a new initParams value inside the loader after download is complete.
 
/
/ called on download complete of each package/file
public void downloadCompleteCallback(Uri packageSource, DownloadCompleteEventArgs e)  
{
  
System.Windows.Browser.HtmlPage.Plugin.SetProperty("initParams","testValue=123");
  
XapUtil.setCurrentXapFile(packageSource);
}

------------------

In both of the above examples you will have a new value called "testValue" in initParams that you can use in the target xap ->

private void Application_Startup(object sender, StartupEventArgs e)
{
  ....
  x = e.InitParams["testValue"] ;
}