Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Image not showing in image control
10 replies. Latest Post by Wilfred Pinto on May 5, 2008.
(0)
brettr
Member
119 points
123 Posts
05-04-2008 4:59 PM |
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
All-Star
17441 points
3,172 Posts
05-04-2008 6:38 PM |
Where did you put your "myimage.png" file?
05-04-2008 9:40 PM |
It is in the folder with the XAML and CS files. The XAP is two folders down in bin\debug.
05-04-2008 10:09 PM |
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).
05-04-2008 10:33 PM |
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.
05-04-2008 10:50 PM |
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.
05-05-2008 12:46 AM |
I tried a gif file and also the absolute path. Still no image.
05-05-2008 10:42 AM |
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.
05-05-2008 11:13 AM |
Nope - PNG doesn't display.
05-05-2008 3:02 PM |
Please show your XAML.
Wilfred ...
Participant
1318 points
258 Posts
05-05-2008 5:07 PM |
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 Pintohttp://projectsilverlight.blogspot.com