Controlling Silverlight outside of the plugin - the .Content property


Posted on January 31, 2008
Filed Under:   1.0 Javascript, Uncategorized |

This one is pretty basic but it is useful and the info doesn’t seem to be easily accessible so I decided to post a quick example. You can use the content property of the plugin to gain access to elements in your XAML.

So say you want to have a link or button on your page control some aspect of your Silverlight App, like load a new Video into a MediaElement, you could do something like this:

function loadVideo(wmv_file) {    

   var videoRef
   var controlRef
   controlRef=document.getElementById("SilverlightControl")
   videoRef=controlRef.content.findName("videoElement")
   videoRef.source=wmv_file 

}

and then in you could just call the loadVideo function within an onclick, onmousdown, or in the href like so:

a href="javascript:loadVideo('my_video.wmv')" mce_href="javascript:loadVideo('my_video.wmv')"

Comments

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

Recently


Categories


Archives


Resources