2

I have a RibbonSpitButton with an ItemSource and an ItemTemplate defined in this way:

<RibbonSplitButton x:Name="SplitButton3DViews" 
                                   ItemsSource="{Binding items}"
                                   Label="{String Views3D}"
                                   IsCheckable="False">
    <RibbonSplitButton.ItemTemplate>
        <DataTemplate>
            <RibbonMenuItem Header="{Binding Name}" ImageSource="{Binding Icon}" Command="{Binding cmd}"/>
        </DataTemplate>
    </RibbonSplitButton.ItemTemplate>
</RibbonSplitButton>

Everithing works but the graphical results is this: enter image description here

How can I put icons of sub-items in the proper place (in the blue part of the menu)?

4

1 回答 1

8

RibbonMenuItem您可以在资源中创建样式并在RibbonSplitButton那里设置适当的属性。

<ribbon:RibbonSplitButton x:Name="SplitButton3DViews" 
               ItemsSource="{Binding items}"
               Label="Views3D"
               IsCheckable="False" >
    <ribbon:RibbonSplitButton.Resources>
        <Style TargetType="{x:Type ribbon:RibbonMenuItem}">
            <Setter Property="Header" Value="{Binding Path=Name}" />
            <Setter Property="Command" Value="{Binding Path=cmd}" />
            <Setter Property="ImageSource" Value="{Binding Icon}" />
        </Style>
    </ribbon:RibbonSplitButton.Resources>                        
</ribbon:RibbonSplitButton>

结果:

在此处输入图像描述

于 2013-03-25T18:19:49.233 回答