RibbonMenuItem 不显示图标
我在 RibbonSplitButton 中有以下代码(在 3.5 功能区 CTP 版本上正确呈现)。我尝试使用 WPF Ribbon 4.0 库查看它,但它只是不渲染图标。知道为什么吗?
<ribbon:RibbonMenuItem Header="Option 3 - icon">
<ribbon:RibbonMenuItem.Icon>
<Image Width="16" Height="16" Source="Images/wizard-icon16.png"></Image>
</ribbon:RibbonMenuItem.Icon>
</ribbon:RibbonMenuItem>
I have the following code inside a RibbonSplitButton (which rendered correctly on the 3.5 ribbon CTP verion). I tried to view it using the WPF Ribbon 4.0 library, but it's just not rendering the Icon. Any idea why?
<ribbon:RibbonMenuItem Header="Option 3 - icon">
<ribbon:RibbonMenuItem.Icon>
<Image Width="16" Height="16" Source="Images/wizard-icon16.png"></Image>
</ribbon:RibbonMenuItem.Icon>
</ribbon:RibbonMenuItem>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不要使用从
MenuItem
继承的 Icon 属性,并且 Ribbon 控件不使用该属性。请改用ImageSource
属性。Don't use the Icon property, that is inherited from
MenuItem
, and isn't used by the Ribbon control. Use theImageSource
property instead.我也看到同样的问题。我尝试在 Icon 属性中放入简单的文本,但它只是不显示任何内容。
我检查了控件模板,发现其中没有绑定到 Icon 属性。您可以使用 ImageSource 将图像放置在菜单项图标的位置。
我猜这只是糟糕的控制模板。
I also see the same problem. I've try to put even simple text in the Icon property but it just does not show anything.
I've check the control template and there is just no binding to the Icon property in it. You can use ImageSource to put an image in the menu item icon's place.
I guess it simply bad control template.
在图像前面添加正斜杠并执行重建解决方案。假设 Images 目录位于项目的根目录。图像的构建操作是否设置为 Content?
华泰
Add a forward slash in front of Images and do a Rebuild Solution. This is assuming the Images directory is located at the root of your project.Is the image's build action set to Content?
HTH
尝试将图像的构建操作设置为资源
Try setting the image's build action to Resource