RibbonGroupsPanel ...仅接受 IProvideStarLayoutInfo 实例?

发布于 2024-10-20 00:04:37 字数 810 浏览 7 评论 0 原文

我试图在我的应用程序中使用 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>

I am trying to use a RibbonGallery in my application, but I get this error at runtime, when the tab which contains the gallery is loaded:

"RibbonGroupsPanel RegisterStarLayoutProvider and
UnregisterStarLayoutProvider accepts only IProvideStarLayoutInfo
instances. Parameter name: starLayoutInfoProvider"

Any idea what isn't right?

Here's the code:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

‘画卷フ 2024-10-27 00:04:37

RibbonGallery 控件必须放置在可以利用 RibbonGallery 的控件中,例如 RibbonSplitButton 或 RibbonComboBox。以下是在 RibbonComboBox 中使用库的示例:

<ribbon:RibbonComboBox Label="1" 
                  SmallImageSource="Images/RightArrowShort_Green16.png"
                  SelectionBoxWidth="62"
                  VerticalAlignment="Center" 
                  IsEditable="True" >
    <ribbon:RibbonGallery SelectedValue="Green"
                          SelectedValuePath="Content"
                          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>
</ribbon: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:

<ribbon:RibbonComboBox Label="1" 
                  SmallImageSource="Images/RightArrowShort_Green16.png"
                  SelectionBoxWidth="62"
                  VerticalAlignment="Center" 
                  IsEditable="True" >
    <ribbon:RibbonGallery SelectedValue="Green"
                          SelectedValuePath="Content"
                          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>
</ribbon: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.

负佳期 2024-10-27 00:04:37

System.Windows.Controls.Ribbon.Primitives 的 RibbonMenuItemsPanel 类允许将 RibbonGallery 放置在 RibbonGroup 中。此类实现 ISupportStarLayout 接口。

在 Window 元素中定义原语命名空间(也可以是 RibbonWindow):

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
        xmlns:primitives="clr-namespace:System.Windows.Controls.Ribbon.Primitives;assembly=System.Windows.Controls.Ribbon" 
        ... >

RibbonGroup 部分:

<RibbonGroup Header="MyRibbonGroup">
    <primitives:RibbonMenuItemsPanel Margin="0,3,0,0">
        <RibbonGallery ...>
            <RibbonGalleryCategory ...>
                ...
            </RibbonGalleryCategory>
        </RibbonGallery>
    </primitives:RibbonMenuItemsPanel>
</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):

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
        xmlns:primitives="clr-namespace:System.Windows.Controls.Ribbon.Primitives;assembly=System.Windows.Controls.Ribbon" 
        ... >

The RibbonGroup-part:

<RibbonGroup Header="MyRibbonGroup">
    <primitives:RibbonMenuItemsPanel Margin="0,3,0,0">
        <RibbonGallery ...>
            <RibbonGalleryCategory ...>
                ...
            </RibbonGalleryCategory>
        </RibbonGallery>
    </primitives:RibbonMenuItemsPanel>
</RibbonGroup>

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.

酷炫老祖宗 2024-10-27 00:04:37

我在您的 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 .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文