我刚刚启动了一个非常简单的WPF应用程序,它由一个主大图像和四个小图像组成。
为了帮助布局,我在mspaint中创建了一些包含图像的jpeg
-2
,
-1
,
0
,
+1
和
+2
并将它们复制到项目目录的顶层。
XAML段包含五个图像:
<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" />
当我试图设置plus2图像的source属性时,它会抱怨一个对话框,其中说明:
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'.
但是,如果我将文件重命名为plus3.jpg或plus2x.jpg,我就没有这个问题。
为什么它特别抱怨plus2.jpg?