locked
Image control does not display image RRS feed

  • Question

  • I am new to Silverlight 2.  I am trying to display an image in a grid:

    <UserControl x:Class="Solution1.Page"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Width="800" Height="600">

    <Grid x:Name="Layout" Background="Black" Width="800" Height="600">

    <Image x:Name="MyImage" Source="../images/100_0450.jpg"></Image>

    </Grid>

    </UserControl>

    I have tried various versions of the Source property.  My folder structure:

    Solution1>
      Solution1.sln
     images>
       100_0450.jpg
     Solution1>
       Solution1.csproj
       App.xaml.cs
       ...
       ...

    I have also tried putting the image in the same folder with the xaml and removed the "/images" from the Source property.  Any assistance is greatly appreciated.

    Sunday, July 26, 2009 8:59 PM

Answers

  • Make sure the image is markes as a resource in the build action.  Ken's suggestion looks correct for teh path.  Remember that relative paths start from the .xap file.

    Sunday, July 26, 2009 11:14 PM

All replies

  • This should work

    <Image x:Name="MyImage" Source="images/100_0450.jpg"></Image>

    Sunday, July 26, 2009 9:38 PM
  • Make sure the image is markes as a resource in the build action.  Ken's suggestion looks correct for teh path.  Remember that relative paths start from the .xap file.

    Sunday, July 26, 2009 11:14 PM