RibbonGroupsPanel ...仅接受 IProvideStarLayoutInfo 实例?
我试图在我的应用程序中使用 RibbonGallery,但是当加载包含图库的选项卡时,我在运行时收到此错误:
“RibbonGroupsPanel RegisterStarLayoutProvider 和 UnregisterStarLayoutProvider 仅接受 IProvideStarLayoutInfo 实例。参数名称:starLayoutInfoProvider"
知道哪里不对吗?
代码如下:
<ribbon:RibbonGallery MaxColumnCount="1">
<ribbon:RibbonGalleryCategory>
<ribbon:RibbonGalleryItem Content="Green" Foreground="Green" />
<ribbon:RibbonGalleryItem Content="Blue" Foreground="Blue" />
<ribbon:RibbonGalleryItem Content="Orange" Foreground="Orange" />
</ribbon:RibbonGalleryCategory>
</ribbon:RibbonGallery>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
RibbonGallery 控件必须放置在可以利用 RibbonGallery 的控件中,例如 RibbonSplitButton 或 RibbonComboBox。以下是在 RibbonComboBox 中使用库的示例:
从 http://msdn.microsoft.com/en-us/library/microsoft.windows.controls.ribbon.ribbongallery.aspx。
如果控件派生自 RibbonMenuButton,则由于 HasRibbon 属性,它可以包含 RibbonGallery。
The RibbonGallery control must be placed within a control that can take advantage of the RibbonGallery, like a RibbonSplitButton or a RibbonComboBox. Here is an example of using a gallery in a RibbonComboBox:
XAML copied from http://msdn.microsoft.com/en-us/library/microsoft.windows.controls.ribbon.ribbongallery.aspx.
If a control is derived from RibbonMenuButton then it can contain a RibbonGallery because of the HasRibbon property.
System.Windows.Controls.Ribbon.Primitives 的 RibbonMenuItemsPanel 类允许将 RibbonGallery 放置在 RibbonGroup 中。此类实现 ISupportStarLayout 接口。
在 Window 元素中定义原语命名空间(也可以是 RibbonWindow):
RibbonGroup 部分:
请注意,我使用 System.Windows.Controls.Ribbon 命名空间(.Net 4.5)而不是 Microsoft.Windows.Controls。功能区命名空间。但这应该是差不多的。
The RibbonMenuItemsPanel-class of the System.Windows.Controls.Ribbon.Primitives allows to place a RibbonGallery in a RibbonGroup. This class implements the ISupportStarLayout-interface.
Define the primitives-Namespace in the Window-element (could also be RibbonWindow):
The RibbonGroup-part:
Note that i use the System.Windows.Controls.Ribbon-namespace (.Net 4.5) and not the Microsoft.Windows.Controls.Ribbon-namespace. But this should be nearly the same.
我在您的 xaml 中没有看到任何 RibbonGroupsPanel,这让我认为您没有显示所有相关的 xaml。
无论如何,它都会告诉您在 RibbonGroupsPanel.RegisterStarLayoutProvider 中放置了错误的元素,并且它仅接受实现 IProvideStarLayoutInfo 的类型。
I don't see any RibbonGroupsPanel in your xaml which leads me to thinking that you're not showing all of the relevant xaml.
In any case, it tells you that you're putting the wrong element inside RibbonGroupsPanel.RegisterStarLayoutProvider and that it accepts only types that implements IProvideStarLayoutInfo .