Did You Know… There are two ways to pass data to your Silverlight 1.0 control on creation

CreateSilverlight() and its wrapper, CreateSilverlightEx() both take an optional sixth and seventh parameter. The sixth, initParam takes a string parameter that you can easily fetch in your javascript code; it becomes an attribute of the Silverlight control (plugin) itself.

For example, you can modify the starter sample that Visual Studio 2008 creates for you by adding this line to Default.html.js:

 

parametersix 

The sixth parameter must be a string. How you use that string is entirely up to you.  . To see using this parameter at work, modify HandleMouseUp in  Scene.xaml.js as follows:

handleMouseUp: function(sender, eventArgs) 
{
    var mouseUpAnimation = sender.findName("mouseUp");
    mouseUpAnimation.begin(); 
var paramValue = this.plugIn.initParams; alert(paramValue); }

In this case, you're accessing the value of the parameter passed in by the user, and placing it into the alert box when the button is clicked.

passingcontent

 
 
Unknown's avatar

About Jesse Liberty

** Note ** Jesse is currently looking for a new position. You can learn more about him at https://jesseliberty.bio Thank you. Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen online courses. His latest book, Building APIs with .NET, is now available wherever you buy your books. Liberty was a Team Lead and Senior Software Engineer for various corporations, a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a 13 year Microsoft MVP.
This entry was posted in z Silverlight Archives. Bookmark the permalink.