Michael Kramer

I'm trying to change an image's source property in JavaScript. With some images, this line of code:

image["source"] = "newimagepath";

throws this error in JavaScript:

"Unexpected call to method or property access."

Has anyone else seen this error Thanks!



Re: Silverlight (formerly WPF/E) Developer Issues "Unexpected call to method or property access." when changing an image's source property.

Mark Rideout

That should work. Does it work if you change the line of code to
image.source = "newimagepath";


-mark
Program Manager
Microsoft
This post is provided "as-is"





Re: Silverlight (formerly WPF/E) Developer Issues "Unexpected call to method or property access." when changing an image's source property.

Michael Kramer

I changed the syntax and it behaves the same way.  I'm open to any other suggestions you may have.

Thanks for you help!

-Michael





Re: Silverlight (formerly WPF/E) Developer Issues "Unexpected call to method or property access." when changing an image's source property.

Mark Rideout

How do you get your image object Can you show the XAML that the image is defined in

-mark
Program Manager
Microsoft
This post is provided "as-is"





Re: Silverlight (formerly WPF/E) Developer Issues "Unexpected call to method or property access." when changing an image's source property.

Michael Kramer

The image sits directly in the root canvas object. I'm not starting with a source property -- I'm dynamically adding it through JavaScript in the root canvas's "loaded' event:

<Image Canvas.Top="155" Canvas.Left="10" Width="160" x:Name="Logo2" Opacity="0" />





Re: Silverlight (formerly WPF/E) Developer Issues "Unexpected call to method or property access." when changing an image's source property.

Mark Rideout

I'll try this out. Does it work if you use different images I've seen one or two bugs on the image not being able to load.

-mark
Program Manager
Microsoft
This post is provided "as-is"





Re: Silverlight (formerly WPF/E) Developer Issues "Unexpected call to method or property access." when changing an image's source property.

Michael Kramer

It works with most images -- there doesn't seem to be a pattern revolving around the ones that don't.

-Michael Kramer





Re: Silverlight (formerly WPF/E) Developer Issues "Unexpected call to method or property access." when changing an image's source property.

Mark Rideout

Can you send me one of the images that does not work
markri@microsoft.com

-mark
Program Manager
Microsoft
This post is provided "as-is"





Re: Silverlight (formerly WPF/E) Developer Issues "Unexpected call to method or property access." when changing an image's source property.

Mark Rideout

Michael - Please send me an image that doesn't work when you can.

thanks!
-mark
Program Manager
Microsoft
This post is provided "as-is"





Re: Silverlight (formerly WPF/E) Developer Issues "Unexpected call to method or property access." when changing an image's source property.

Henry Stapp

Hi Mark,

I'm also encountering this issue. I'm emailing you a sample that demonstrates the problem.

Thanks,

Henry