views:

64

answers:

2

I'm working on a small silverlight application that involves passing some data between javascript and silverlight. I am also using the silverlight virtual earth control.

The weirdness I have come across is that is possible to register Microsoft.Maps.MapControl.LocationCollection as a script createable type and instantiate and pass it to a ScriptableMember. This is great, but I can't see where LocationCollection is tagged as a ScriptableType - am I missing something obvious.

Code in App.xaml.cs - Application_Startup

HtmlPage.RegisterCreateableType("mapLocationCollection", typeof(Microsoft.Maps.MapControl.LocationCollection));

Javascript code that works!

var locs = SLPlugin.Content.services.createObject('mapLocationCollection');

I thought that in order in instantiate an instance of the class in JavaScript the type needed to be tagged as [ScriptableType] and the type needs to be registered as a createable type. As far as I can tell LocationCollection (or any of it's superclasses) have this attribute.

Can anyone out there help me square this in my mind?

A: 

No the ScriptableType attribute specifies that all public properties, methods and events on the type are scriptable. This simply saves having mark them all with ScriptableMember.

AnthonyWJones
Is that right? The material I have says that the RegisterScriptableObject method (System.Windows.Browser.HtmlPage) associates an instance of a scriptable object (its class is decorated with ScriptableType) with a string alias. Page 324 of Accelerated Silverlight 3 - apress.com.
Stephen Newman
Read the remarks section of the documentation: http://msdn.microsoft.com/en-us/library/system.windows.browser.scriptabletypeattribute(VS.95).aspx
AnthonyWJones
Many thanks, I can sleep at night now :)
Stephen Newman
A: 

Hi, has any one used the Extended Mode Library.

Am having a fairly basic issue with accessing the map through mapControl.Content.map

I have tried many possibilities, mapControl.Content isn't null neither is mapControl.content.services to this means many of the things are actually supported of the Bing Maps Silverlight Controls. Please help.

sameerfair