views:

371

answers:

1

Silverlight newbie question:

I've got a small Silverlight application with the following XAML snippet:

<Image Source="http://judahhimango.com/images/smileys/cool.gif" />

The image doesn't show up! I would expect the image to download asynchronously, then show up in the UI, but alas, no such luck.

What am I doing wrong?

Update -------------------------------------------------

Ok, no-go on the .GIFs, forgot about that. But using a PNG doens't work either:

<Image Source="http://judahhimango.com/images/smileys/cool.png" />

However, if I change the Source to a BitmapImage, then it works:

<Image>
      <Image.Source>
         <BitmapImage UriSource="http://judahhimango.com/images/smileys/cool.png" />
      </Image.Source>
</Image>

Why can't I just specify the Image Source? Why do I have to specify a BitmapImage?

+1  A: 

I think SL does not support gifs: http://forums.silverlight.net/forums/p/3883/232781.aspx can you try a jpg?

3/9/10: Editing per request: I can't post complete code, but here is my MainPage.xaml

<UserControl x:Class="SilverlightApplication2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
        <Image Source="http://judahhimango.com/images/smileys/cool.png"/&gt;
    </Grid>
</UserControl>

3/9/10: OK, I think I know what your problem may be. When you create a new silverlight application project in Visual Studio, it gives you the option of hosting it in an ASP.NET website. Did you select that option? If not, please select it, and give it a try. See this: http://stackoverflow.com/questions/1053081/deep-zoom-is-not-displayed/2413697#2413697

morpheus
Ah, that would explain it, wouldn't it? :-) Thanks, I'll give a jpg a try.
Judah Himango
PNG still doesn't work. If I change the Image's Source property to a BitmapSource, then it works. I'm updating the question, perhaps you can update your answer?
Judah Himango
Updated the question. Please have a look; if it works out, I'll gladly mark yours as the answer and vote you up.
Judah Himango
Looks like the comment mangled that. Can you edit your post instead with that? Then I'll give it a try.
Judah Himango
I am not able to edit previous comment. I am not having any problem with <Image Source="judahhimango.com/images/smileys/cool.png"/> inserted in a Grid.
morpheus
Really? That's bizarre, I am having that problem. Which Silverlight version are you using?
Judah Himango
@Morpheus: please don't post significant code in comments it just doesn't format well, edit your answer to include the code there.
AnthonyWJones
using 3.0. although i did not try, i expect 2.0 should also work. i deleted my old comment, which did not format well.
morpheus
morpheus, for the sake of the internet audience, would you mind editing your post to include the code sample?
Judah Himango
Now that I've upgraded to SL 4, I never have these problems. I think this was a rare, intermittent bug in SL 3 that has now been fixed in SL 4.
Judah Himango