Skip to main content

Microsoft Silverlight

Answered Question How to return javascript dictionary object to silverlight method ?RSS Feed

(0)

narzis
narzis

Member

Member

7 points

7 Posts

How to return javascript dictionary object to silverlight method ?

How can i javascript dictionary object in Silverlight?

Javascript code

function GetStatus(contacts)
{
    var ht = {};
    if (contacts.length) {    
        for (var i=0; i < contacts.length; i++) {
           
            var foundContact = _communicatorObj.GetContact(contactsIdea, _communicatorObj.MyServiceId);
            alert(contactsIdea + ", " + foundContact.Status);
            ht[contactsIdea] = foundContact.Status;
        }
    }

    alert(ht.toString());
    return ht;
}

Silverlight

Dictionary<string, object> statusDic = HtmlPage.Window.Invoke("GetStatus", jsContacts) as Dictionary<string, object>;

statusDic is always null!

as i know, Javascript dictionaries can be converted to Dictionary<string, object>.

http://msdn.microsoft.com/en-us/library/cc645079(VS.95).aspx

How can i this?

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Answered Question

Re: How to return javascript dictionary object to silverlight method ?

I think this is a bug in Beta 2.  Hopefully it'll be fixed in the Release.  I found this same behavior when I was writing a wrapper for GoogleGears.

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities