图像显示在设计师,但驱动图像时,如调试在vs2013运行它给人的错误: 此外,如果exe文件直接在同一文件夹中的图像跑。设置窗口背景从上运行
information: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '12' and line position '10'.
错误是bcoz它找不到图像。在xaml视图中,当鼠标悬停在图像上时,它说:
project file expected in c:\user\bsienn\docs\vs2013\project\wpf1\wpf1\image1.jpg
尽管图片确实在那条路径上并且可用。
我想添加一个图像作为窗体的背景,我不想在资源中添加图像,bcoz我希望在需要时更改图像。我已经把exe文件放在图像上,并试图将它放在bin/debug和主应用程序文件夹(wpf1/image1.jpg andalso wpf1/wpf1/image1.jpg)中。
这里是XAML代码,请指导
<Window.Background>
<ImageBrush ImageSource="image1.jpg"/>
</Window.Background>
App structure:
app.exe
image1.jpg
Desired outcome, form with background image
我知道该怎么做,但我不想在资源中添加图像,bcoz我希望在需要时更改图像。所以我需要从可执行路径中获取图像所在的位置 – ADi
我很害怕,没有在项目中添加图像作为资源是不可能的。 –
omg :(这太奇怪了,它不可能,但是4时间 – ADi