开发者

C#, WPF, Embedded resources/embedded resources

开发者 https://www.devze.com 2023-03-29 11:21 出处:网络
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 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:string开发者_如何转开发s.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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消