按钮的图像未出现在上下文菜单中
Image of Button does not appear on Contextmenu
我在标准上下文菜单(右键单击菜单)中添加了一个按钮。到目前为止效果很好。但是我在按钮前面添加图像时遇到了一些麻烦。
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<contextMenus>
<contextMenu idMso="ContextMenuText">
<button id="startResearch" label="Start Research!" insertBeforeMso="HyperlinkInsert" onAction="startResearchClick" showImage="true" visible="true" image="pack://application:,,,/Resources/magnifying_glass.png"/>
</contextMenu>
</contextMenus>
</customUI>
image="pack://application:,,,/Resources/magnifying_glass.png"/>
您不能以这种方式指定资源或图像路径。
在功能区 XML 标记中指定图像的主要方法有两种:
用于加载图像的元素中的 loadImage 回调和用于在控件中指定图像 ID 的 image 属性.通过使用此技术,您可以编写 returns 自定义所需的所有图像的单个回调过程,而无需编写每个单独控件的 getImage 回调。请注意,当您调用 Ribbon 的 Invalidate 方法或 InvalidateControl 方法时,不会再次调用 loadImage 回调。对于需要在运行时间动态改变图片的控件,使用getImage回调。
控件的getImage属性。允许 load/change 动态图像。
您可以在 MSDN 中的以下系列文章中阅读更多相关信息:
我在标准上下文菜单(右键单击菜单)中添加了一个按钮。到目前为止效果很好。但是我在按钮前面添加图像时遇到了一些麻烦。
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<contextMenus>
<contextMenu idMso="ContextMenuText">
<button id="startResearch" label="Start Research!" insertBeforeMso="HyperlinkInsert" onAction="startResearchClick" showImage="true" visible="true" image="pack://application:,,,/Resources/magnifying_glass.png"/>
</contextMenu>
</contextMenus>
</customUI>
image="pack://application:,,,/Resources/magnifying_glass.png"/>
您不能以这种方式指定资源或图像路径。
在功能区 XML 标记中指定图像的主要方法有两种:
用于加载图像的元素中的 loadImage 回调和用于在控件中指定图像 ID 的 image 属性.通过使用此技术,您可以编写 returns 自定义所需的所有图像的单个回调过程,而无需编写每个单独控件的 getImage 回调。请注意,当您调用 Ribbon 的 Invalidate 方法或 InvalidateControl 方法时,不会再次调用 loadImage 回调。对于需要在运行时间动态改变图片的控件,使用getImage回调。
控件的getImage属性。允许 load/change 动态图像。
您可以在 MSDN 中的以下系列文章中阅读更多相关信息: