I am trying to add a png image resource in a specific Silverlight project folder. I would like to refer to this image with in my tag? I only seem to get this working when the xaml file containing the image tag is located in the same directory as the png file.
我正在尝试在特定的Silverlight项目文件夹中添加png图像资源。我想在我的标签中引用这张图片?当包含image标签的xaml文件与png文件位于同一目录时,我似乎只能使用它。
For example in the xap file the png file would be located in xap\resource\image1.png and my xaml file would reside in the root directory xap\consumeImageA.xaml.
例如,在xap文件中,png文件位于xap \ resource \ image1.png中,而我的xaml文件将驻留在根目录xap \ consumeImageA.xaml中。
3 个解决方案
#1
2
I have found a blog post discussing USING URIS IN EXPRESSION BLEND which works for me.
我找到了一篇博文,讨论了使用URIS IN EXPRESSION BLEND,这对我有用。
pack://application:,,,/Images/happyface.png is wrong. This will work from XAML,
but not from code. It needs to bepack:// application:,,, / Images / happyface.png错误。这将来自XAML,但不适用于代码。它需要
pack://application:,,,/WpfApplication6;component/Images/happyface.png If you do this, Blend resolves well
all the time!pack:// application:,,, / WpfApplication6; component / Images / happyface.png如果你这样做,Blend会一直很好地解决!
#2
1
You can specify a relative path from where the XAP file resides, but you can't use .. notation so the images would have to be at the level of the XAP file or lower. Shawn Wildermuth has been playing with putting the XAP file at the web root instead of ClientBin so that you can use relative paths. Alternatively, you can use an absolute path to the image.
您可以指定XAP文件所在的相对路径,但不能使用..表示法,因此图像必须位于XAP文件的级别或更低级别。 Shawn Wildermuth一直在玩XAP文件而不是ClientBin,以便您可以使用相对路径。或者,您可以使用图像的绝对路径。
#3
0
Make sure you use forward slashes, not back slashes. I know that one has bit me in the rear more than once.
确保使用正斜杠,而不是反斜杠。我知道有人不止一次在后方咬我。
So, in your example, you should use resource/image1.png
因此,在您的示例中,您应该使用resource / image1.png
#1
2
I have found a blog post discussing USING URIS IN EXPRESSION BLEND which works for me.
我找到了一篇博文,讨论了使用URIS IN EXPRESSION BLEND,这对我有用。
pack://application:,,,/Images/happyface.png is wrong. This will work from XAML,
but not from code. It needs to bepack:// application:,,, / Images / happyface.png错误。这将来自XAML,但不适用于代码。它需要
pack://application:,,,/WpfApplication6;component/Images/happyface.png If you do this, Blend resolves well
all the time!pack:// application:,,, / WpfApplication6; component / Images / happyface.png如果你这样做,Blend会一直很好地解决!
#2
1
You can specify a relative path from where the XAP file resides, but you can't use .. notation so the images would have to be at the level of the XAP file or lower. Shawn Wildermuth has been playing with putting the XAP file at the web root instead of ClientBin so that you can use relative paths. Alternatively, you can use an absolute path to the image.
您可以指定XAP文件所在的相对路径,但不能使用..表示法,因此图像必须位于XAP文件的级别或更低级别。 Shawn Wildermuth一直在玩XAP文件而不是ClientBin,以便您可以使用相对路径。或者,您可以使用图像的绝对路径。
#3
0
Make sure you use forward slashes, not back slashes. I know that one has bit me in the rear more than once.
确保使用正斜杠,而不是反斜杠。我知道有人不止一次在后方咬我。
So, in your example, you should use resource/image1.png
因此,在您的示例中,您应该使用resource / image1.png