i got some trouble. I just implemented the Microsoft Ribbon Framework into my application. Now i wanted to set an icon for one button. So i wrote:
我遇到了麻烦。我刚刚在我的应用程序中实现了Microsoft Ribbon Framework。现在我想为一个按钮设置一个图标。所以我写道:
<Ribbon:RibbonButton Header="Create Project" LargeImageSource="pack://application:,,,/Resources/document_empty.png" />
But everytime i start the app, i got an "XamlParseException" in this line, with the inner exception: "File not found".
但每次我启动应用程序时,我都会在此行中出现“XamlParseException”,内部异常:“找不到文件”。
Why the hell is this so? I don´t understand, why it doesn´t find the image. It´s just placed in the resources of the assembly. The designer show´s it and the code doesn´t get highlighted as it was an syntax error or something like that...
这到底为什么会这样?我不明白,为什么它找不到图像。它只是置于装配的资源中。设计师展示它并且代码没有突出显示,因为它是语法错误或类似的东西......
Anyone who has this problem too?
谁也有这个问题?
Thanks!
谢谢!
1 个解决方案
#1
21
As you haven't specified exactly, I assume you are using the Properties\resources.resx part of your application? If so this is not the desired way for a WPF application.
由于您没有准确指定,我假设您正在使用应用程序的Properties \ resources.resx部分?如果是这样,这不是WPF应用程序的理想方式。
See this post on SO
在SO上看到这篇文章
Instead create a folder in your assembly, place your images in there and set its build action to resource.
而是在程序集中创建一个文件夹,将图像放在那里并将其构建操作设置为资源。
See picture:
见图:
In your Markup use the packUri:
在你的标记中使用packUri:
pack://application:,,,/images/IMG.jpg
包://应用:,,, /图像/ IMG.jpg
#1
21
As you haven't specified exactly, I assume you are using the Properties\resources.resx part of your application? If so this is not the desired way for a WPF application.
由于您没有准确指定,我假设您正在使用应用程序的Properties \ resources.resx部分?如果是这样,这不是WPF应用程序的理想方式。
See this post on SO
在SO上看到这篇文章
Instead create a folder in your assembly, place your images in there and set its build action to resource.
而是在程序集中创建一个文件夹,将图像放在那里并将其构建操作设置为资源。
See picture:
见图:
In your Markup use the packUri:
在你的标记中使用packUri:
pack://application:,,,/images/IMG.jpg
包://应用:,,, /图像/ IMG.jpg