C#、WPF、嵌入式资源/嵌入式资源
我希望在生成的 .exe 文件中包含许多资源,例如许多图像。但我无法从 XAML 文件中的 RibbonCommands 访问这些资源(图像)。
我已标记这些文件并将其属性更改为“嵌入式资源”, 但在代码和 XAML 文件中引用它们会出现问题。
对于主窗口我做了以下操作:
哪个有效!
但 RibbonCommands 似乎无法找到嵌入式资源。
<r:RibbonCommand x:Key="ScanCommand"
LabelTitle="{x:Static const:strings.Scan}"
ToolTipDescription="{x:Static const:strings.ScanToolTip}"
Executed="ScanDisplayUnit"
LargeImageSource="/EasyLink;component/ScanIcon48x48.png"
我收到的错误消息是:
“/EasyLink;component/ScanIcon48x48.png”不是项目的一部分
或者它的“构建操作”属性未设置为“资源”
是否无法在功能区中使用“嵌入资源”?
“嵌入式资源”和“资源”之间的区别是否正确理解为 “嵌入式资源”包括生成的 .exe 文件中的资源,但“资源”不这样做?
I want a number of resources to be included in the resulting .exe file, such as a number of images. But I have trouble to access these resources (images) from the RibbonCommands in the XAML file.
I have marked the files and changed their properties to "Embedded Resources",
but get problem to refer to them in the Code and the XAML file.
For the Main window I have done the following:
Which works!
But the RibbonCommands does not seem to be able to find Embedded resources.
<r:RibbonCommand x:Key="ScanCommand"
LabelTitle="{x:Static const:strings.Scan}"
ToolTipDescription="{x:Static const:strings.ScanToolTip}"
Executed="ScanDisplayUnit"
LargeImageSource="/EasyLink;component/ScanIcon48x48.png"
The error message I got is:
"/EasyLink;component/ScanIcon48x48.png" is not part of the project
Or it's Build Action property is not set to "Resource"
Is it not possible to use "Embedded Resources" in Ribbons?
Is it correctly understood that the different between "Embedded Resource" and "Resource" is that the
"Embedded Resource" include the resources in the resulting .exe file but "Resource" does not do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚对此进行了测试,正如我所想,“嵌入式资源”和“资源”之间的区别不是,一个将资源嵌入到程序集中,另一个则没有。他们都这样做。
我认为主要区别在于“Resource”提供了一种 WPF 应用程序更容易访问的资源管理方案,因此您应该为图像使用该选项。
I just tested this, and as I thought - the difference between "Embedded Resource" and "Resource" isn't that one embeds the resource in the assembly and one doesn't. They both do.
I think the main difference is that "Resource" provides a resource management scheme that is more accessible to WPF applications, so that's the option you should be using for your image.