Skip to main content

Microsoft Silverlight

Unanswered Question Image not showing in image controlRSS Feed

(0)

brettr
brettr

Member

Member

119 points

123 Posts

Image not showing in image control

I've added an image control to a Silverlight 2 application in Blend 2.5.   Then I added the image by clicking the ellipse next to the Source field in the Properties tab.  In XAML, it looks like

Source="myimage.png"

I don't see the image in Blend's preview or when I run the project through VS.NET 2008.   Any suggestions?

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Image not showing in image control

 Where did you put your "myimage.png" file?

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

brettr
brettr

Member

Member

119 points

123 Posts

Re: Re: Image not showing in image control

It is in the folder with the XAML and CS files.  The XAP is two folders down in bin\debug.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Re: Image not showing in image control

So the file is in the silverlight project folder? What is the build action of this file (Check the file property page). If the build action = "none", change it to "Resource" and try it again. The image will be build into the XAP as resource.

 

If it's under the Web project folder, the image file will not be build into the XAP. You do not have to set build action, but you have to change source = "..//myimage.png" (the url is relative to the XAP file).

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

brettr
brettr

Member

Member

119 points

123 Posts

Re: Re: Re: Image not showing in image control

The build action is already resource.  I don't have a web project for this one.  Regardsless, it should show in the Blend and Studio designers.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Re: Re: Image not showing in image control

No, I never saw image show up in the Designer. Actually I never rely on the designer to see my layout because I found the designer is still too buggy at this beta1 release. Same is true for Blend. Sometime when I tried to load the my simplest XAML into blend and got invalid XAML( even tells me UserControl, Grid is invalid Tag). But when I run my app the image shows up right. That's what I really care at this point.

Your file is not gif or bmp format, right? Otherwise they are not supported in the current release.

Other than that, the only thing is the path. Try to put your image file to a folder under your web site and use absolute path and see if it shows up.

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

brettr
brettr

Member

Member

119 points

123 Posts

Re: Re: Re: Re: Image not showing in image control

I tried a gif file and also the absolute path.   Still no image.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Re: Re: Re: Image not showing in image control

Gif file is not supported in the current release. But png file should be fine.

By the way, you said you do not have a web project then how do you test your silverlight control? Where is your SilverlightTest.html page and how do you debug?

 If you could show your UserControl.XAML that would be more helpful.


 

 

 

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

brettr
brettr

Member

Member

119 points

123 Posts

Re: Re: Re: Re: Re: Image not showing in image control

Nope - PNG doesn't display.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Re: Re: Re: Re: Image not showing in image control

 Please show your XAML.

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

Wilfred Pinto
Wilfred ...

Participant

Participant

1318 points

258 Posts

Re: Image not showing in image control

There are issues with certain png files, especially transparent ones.
Check out this post http://silverlight.net/forums/p/6941/21495.aspx#21495

Hope this helps!

Wilfred Pinto
http://projectsilverlight.blogspot.com
 

Wilfred Pinto
http://projectsilverlight.blogspot.com


Please remember to mark the replies as answers if they help answer your question.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities