This post originated from an RSS feed registered with .NET Buzz
by Ashish Shetty.
Original Post: How to pass initialization params to a Silverlight 2 app
Feed Title: Even a chimp can write code
Feed URL: http://nerddawg.blogspot.com/rss.xml
Feed Description: Ideas on software and elsewhere by Ashish Shetty: erstwhile chimp and occasional re-inventor of the wheel.
This is something of an FAQ on our internal discussion lists, so I figured it merited a post.
Step 1: Declare the initParams param on the Silverlight plug-in and pass in a comma-delimited set of key-value pair tokens. For e.g. "key1=value1,key2=value2,key3=value3".
<!-- startPage key can have values Page1 or Page2 -->
<paramname="initParams" value="startPage=Page1"/>
</object>
For best results, the key and value tokens in the initParams string must be restricted to alphanumeric values. There currently isn't support for escaping equality signs or commas, for instance, should they exist in the key or value part of the token.
Step 2: In the Application's Startup event handler, extract the initialization parameters via StartupEventArgs.InitParams property. You'll get an IDictionary<string, string>.