Bizarre problem with WPF XAML file.

Posted by paxdiablo on Stack Overflow See other posts from Stack Overflow or by paxdiablo
Published on 2010-06-10T07:39:41Z Indexed on 2010/06/10 7:42 UTC
Read the original article Hit count: 285

Filed under:
|
|

I've just started a very simple WPF application which consists of a main large image and four smaller images.

In order to assist with the layout, I created some JPEGs in MsPaint containing the images -2, -1, 0, +1 and +2 and just copied them into the top level of the project directory.

The XAML segment contains, for the five images:

<Image Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="4" Grid.RowSpan="1"
    Margin="0,0,0,0" Name="imgPicture" Stretch="Fill" VerticalAlignment="Top"
    Source="file:///C:/DAndS/Pax/MyDocs/VS2008/Projects/MyProj/zero.jpg"
<Image Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="1" Grid.RowSpan="1"
    Margin="0,0,0,0" Name="imgPicMinus2" Stretch="Fill" VerticalAlignment="Top"
    Source="file:///C:/DAndS/Pax/MyDocs/VS2008/Projects/MyProj/minus2.jpg"
<Image Grid.Column="2" Grid.Row="4" Grid.ColumnSpan="1" Grid.RowSpan="1"
    Margin="0,0,0,0" Name="imgPicMinus1" Stretch="Fill" VerticalAlignment="Top"
    Source="file:///C:/DAndS/Pax/MyDocs/VS2008/Projects/MyProj/minus1.jpg"
<Image Grid.Column="3" Grid.Row="4" Grid.ColumnSpan="1" Grid.RowSpan="1"
    Margin="0,0,0,0" Name="imgPicPlus1" Stretch="Fill" VerticalAlignment="Top"
    Source="file:///C:/DAndS/Pax/MyDocs/VS2008/Projects/MyProj/plus1.jpg"
<Image Grid.Column="4" Grid.Row="4" Grid.ColumnSpan="1" Grid.RowSpan="1"
    Margin="0,0,0,0" Name="imgPicPlus2" Stretch="Fill" VerticalAlignment="Top"
    Source="file:///C:/DAndS/Pax/MyDocs/VS2008/Projects/MyProj/plus2.jpg"

When I try to set the source property for the plus2 image, it complains with a dialog box stating:

Property value is not valid.
Details
   |
   V
   The file plus2.jpg is not part of the project or
   its 'Build Action' property is not set to 'Resource'.

Yet if I rename the file to plus3.jpg or plus2x.jpg, I don't have that problem.

Why is it complaining about plus2.jpg specifically?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about xaml