Might not be exactly what you're looking for but you can call methods in the Silverlight classes from JavaScript, if you flag the class with the ScriptableType() attribute & flag the method(s) you want exposed to JavaScript with the ScriptableMethod() attribute. Silverlight objects can also call JS functions in your webpage via the ScriptObject class.calling JS function from within SL-
// in SL code behind -
ScriptObject js = (ScriptObject)HtmlPage.Window.GetProperty("some_js_function");
js.InvokeSelf("called from SL");
//Javascript in page -
function some_js_function(arg) {
alert(arg.toString());
}
Call SL method from JavaScript
// JS function in the page, called by a button's onclick
function Call_SL_Method(arg) {
var sl = document.getElementById("silverlightControl");
sl.content.Page.SetUserName(arg);
}
//in Silverlight Code Behind, decorate the class & method to expose to JS
[ScriptableType()]
public partial class MainPage : UserControl
{
[ScriptableMember()]
public void SetUserName(string name)
{
//txtName is a textblock to hold user name
txtName.Text = name;
}
public MainPage()
{
InitializeComponent();
//register the class with the HtmlPage
HtmlPage.RegisterScriptableObject("Page", this);
....
}