Judah Gabriel Himango
Judah Gabriel Himango

Reputation: 60061

Silverlight Image element not showing up

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?

Upvotes: 0

Views: 5365

Answers (2)

Karen
Karen

Reputation: 21

I changed two properties on my png image: Build Action to Content and Copy to Output Direct Copy always.

Upvotes: 2

morpheus
morpheus

Reputation: 20382

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"/>
    </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: deep zoom is not displayed

Upvotes: 1

Related Questions