Silverlight - Image Not Loading from URI at Runtime?
I've added an image element to my Silverlight app, and while the image pulls right up when in design mode, it doesn't load at all when running the app.
Code is:
<Image Height="95"
HorizontalAlignment="Left"
Margin="12,541,0,0"
Name="imgBannerAd"
Stretch="Fill"
VerticalAlignment="Top"
Width="828" 开发者_JS百科
Source="http://myurl.com/images/theimage.png"
/>
What's the deal? I'd tried running the file via the local hard drive and localhost, neither has any effect.
I would check that
- you don't have a cross domain issue; Peter Bromberg: Handling Cross-Domain Images and Gifs and Tim Heuer: Hosting cross-domain Silverlight applications
- some versions of Silverlight can have png image problems (never noticed this myself) helpful link
This occurs when you test your file using the Visual Studio generated test html file, loaded directly from disk.
If you create an Asp.Net application to host your Silverlight XAP, the problem should go away.
精彩评论