Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7718807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:15:27+00:00 2026-06-01T03:15:27+00:00

I have a Silverlight control with a method named DoSomething() decorated with the <ScriptableMember()>

  • 0

I have a Silverlight control with a method named DoSomething() decorated with the <ScriptableMember()> attribute. I then call this method successfully from JavaScript and proved by a little message box that apprears from the SL side that says “Method Called!”.

Point is all that works. The problem I am having is that prior to calling this method I build up an ObservableCollection on the Silverlight control containing 1..n FileInfo objects. This works fine too and builds up as I add files to it. Each time I add a file, a messagebox tells me the count from Silverlight (i.e. “Count = 2”).

Now the problem: when I call the method DoSomething() from JS and access that ObservableCollection the count = 0! To see what is going on I placed a message in the Silverlight control’s constructor to see if it gets entered upon being called from JS, and indeed it does and appears to recreate the control.

If this is the case it kind of makes sense that my ObservableCollection has a count = 0 because it is not the same control instance where I built up the FileInfo collection.

So how in the world do I preserve the collection, and why would simply calling a method exposed to JS from Silverlight, recreate the control and not allow me to access it’s given state? I don’t want a new control, I need to manipulate it as-is. Or am I off base and doing something else wrong to cause this beahvior?

Thoughts? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:15:29+00:00Added an answer on June 1, 2026 at 3:15 am

    It turns out the instance registered was the culprit. The MSDN examples show registering a new instance of the type, but in my case I needed the actual instance of the Page Control itself which solved the problem.

    So at the completion of my page’s initialization, I could register the current page’s instance like below:

    HtmlPage.RegisterScriptableObject("SLControl", Me)
    

    This allowed me from JS to access the control in it’s current state which included all objects in the ObservableCollection as required. I blogged about this topic with code examples and the article below expands on this situation:

    Get A Silverlight Control’s Current Instance For Communicating Via The HTML Bridge:
    http://allen-conway-dotnet.blogspot.com/2012/03/get-silverlight-controls-current.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight control derived from ContentControl. I use it in following way
I have a problem styling/templating an AccordionItem in the accordion control from the silverlight
I am trying to create a TreeView from the Silverlight TreeView control. I have
I have the following (2) 'ScriptableMember' types in my Silverlight control: <ScriptableMember()> Public Property
I have a Silverlight control which maintains a set of children. This set of
There is this Telerik's RadTreeView (Silverlight Version) control I'd like to extend (inherit from).
I have a Silverlight user control that has an Image control within it. This
I have a Silverlight control with a Content field. I'd like to be able
I have a Silverlight custom control with two properties; Text and Id. I have
I have a silverlight upload control. It handles drag&drop for files, quite good. Users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.