none
why does Image Source not work for some image file ?

    Question

  • I would like to add the image to a button e.g.

    <Button Width="100" Height="100">
            <Image Source="tom.PNG" />
     </Button>

    This works fine.  But when I use a different image file e.g.

    <Button Width="100" Height="100">
            <Image Source="image1.jpg" />
    </Button>

    I got: Error    1    The file image1.jpg is not part of the project or its 'Build Action' property is not set to 'Resource'.

    Why does it work for some image file but not the other ?

    Would some one tell me what the difference is ?

    Thanks
    Friday, September 05, 2008 7:55 PM

Answers

  • You should check the property of Tom.Png and Image1.jpg. Make sure they are included in this project and have same properties.

    Hope this helps.

    Yiling, MVP(Visual C++)
    • Proposed as answer by Jim Zhou - MSFT Tuesday, September 09, 2008 4:49 AM
    • Unproposed as answer by Bathoi Tuesday, September 09, 2008 8:34 PM
    • Proposed as answer by Jim Zhou - MSFT Friday, September 12, 2008 8:34 AM
    • Marked as answer by Marco Zhou Friday, September 12, 2008 10:06 AM
    Saturday, September 06, 2008 3:14 AM

All replies

  • You should check the property of Tom.Png and Image1.jpg. Make sure they are included in this project and have same properties.

    Hope this helps.

    Yiling, MVP(Visual C++)
    • Proposed as answer by Jim Zhou - MSFT Tuesday, September 09, 2008 4:49 AM
    • Unproposed as answer by Bathoi Tuesday, September 09, 2008 8:34 PM
    • Proposed as answer by Jim Zhou - MSFT Friday, September 12, 2008 8:34 AM
    • Marked as answer by Marco Zhou Friday, September 12, 2008 10:06 AM
    Saturday, September 06, 2008 3:14 AM
  • Thanks for your reply.

    Both of these images files are added into the project in the same way (through Adding Existing items ...).

    Both have the same properties (i.e. Build Action property set to Resource, and Copy to Output property set to Do not Copy).
    Tuesday, September 09, 2008 8:42 PM