RibbonGroupsPanel ...只接受IProvideStarLayoutInfo实例?

问题描述 投票:1回答:3

我试图在我的应用程序中使用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>
wpf gallery ribbon
3个回答
3
投票

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>

XAML从http://msdn.microsoft.com/en-us/library/microsoft.windows.controls.ribbon.ribbongallery.aspx复制。

如果控件是从RibbonMenuButton派生的,那么由于HasRibbon属性,它可以包含RibbonGallery。


1
投票

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

在Window-element中定义primitives-Namespace(也可以是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.Ribbon命名空间。但这应该差不多了。


0
投票

我没有在你的xaml中看到任何RibbonGroupsPanel,这让我觉得你没有显示所有相关的xaml。

在任何情况下,它都会告诉您在RibbonGroupsPanel.RegisterStarLayoutProvider中放置了错误的元素,并且它只接受实现IProvideStarLayoutInfo的类型。

© www.soinside.com 2019 - 2024. All rights reserved.