Skip to main content
Home Forums General Silverlight Getting Started How can I tell in javascript when a silverlight control is fully loaded?
1 replies. Latest Post by ccoombs on July 1, 2009.
(0)
bpeters
Member
1 points
10 Posts
07-01-2009 11:51 AM |
I have a page that dynamically creates a silverlight control, using the provided function "Silverlight.createObjectEx."
This generally works fine, but I'm running into a problem. I need to load the control, and then have javascript make a call into the control to pass in some data. The problem is that if I create the object, and then immediately call the exposed function, I get an exception on the page. If I put in a hack to have javascript sleep for a few seconds,and then I make the same call into the silverlight object, it works as expected.
Is there any way to detect when a silverlight control is ready for the containing page to communciate with it via javascript?
Thanks
ccoombs
Contributor
5168 points
758 Posts
07-01-2009 2:20 PM |
perhaps someone has a more 'official' solution, but it seems like you'd be able to invoke a javascript function with Browser.HtmlPage.Window.Eval("someJavascriptFunction();") in the Loaded event of Page.xaml.
the loaded event fires when the silverlight object is loaded and ready for interaction. then of course 'someJavascriptFunction' would be able to interact with it.