Tony Stark
Tony Stark

Reputation: 1

GroupSizeDefinition is not working with style defined for ribbon group

I have a main list which is a ribbon group. Inside each ribbon group there is another list called subfuctions for ribbon buttons.

<DataTemplate x:Key="buttonTempl">
                <RibbonButton IsEnabled="{Binding IsEnabled}" Label="{Binding Path=SubFunctionName}" Command="{Binding SubFunctionCommand}" LargeImageSource="{Binding LargeButtonImage}" SmallImageSource="{Binding SmallButtonImage}"/>
            </DataTemplate>
            <RibbonGroupSizeDefinitionBaseCollection x:Key="groupSize">
                <RibbonGroupSizeDefinition IsCollapsed="False" />
            </RibbonGroupSizeDefinitionBaseCollection>
            <Style TargetType="RibbonGroup" x:Key="groupStyle">
                <Setter Property="GroupSizeDefinitions" Value="{StaticResource groupSize}"/>
                <Setter Property="Header" Value="{Binding DisplayName}"/>
                <Setter Property="ItemsSource" Value="{Binding SubFunctions}"/>
                <Setter Property="ItemTemplate" Value="{StaticResource buttonTempl}"/>
                <Setter Property="SmallImageSource" Value="{Binding RibbonGroupSmallImageSource}"/>
                <Setter Property="Margin" Value="0"/>
            </Style>
            <Style TargetType="RibbonTab" x:Key="tabStyle">
                <Setter Property="Header" Value="Pump"/>
                <Setter Property="ItemsSource" Value="{Binding MainFunctions}"/>
                <Setter Property="ItemContainerStyle" Value="{StaticResource groupStyle}"/>
            </Style>

Hence groupSizedefinition is working if I use ribbongroup as separate as below: <RibbonGroup Header="Selection" Name="SelectionMenu" GroupSizeDefinitions="{StaticResource groupSize}"> but not working with the above code that is with template.

What could be done to work groupsizedefinition with ribbongroup defined as style?

Upvotes: 0

Views: 96

Answers (1)

Phil Jollans
Phil Jollans

Reputation: 3769

This is not really an answer, but it is too much for a comment.

I tried to reproduce this problem and observed the following effects using the "Live Visual Tree" and the "Live Property Explorer" windows in the debugger.

Specifying the GroupSizeDefinitions explicitly

<RibbonGroup Style="{StaticResource groupStyle}" GroupSizeDefinitions="{StaticResource groupSize}" />

the GroupSizeDefinitions in the style is crossed out, and the local definition is used

enter image description here

Specifying the GroupSizeDefinitions in the styls

<RibbonGroup Style="{StaticResource groupStyle}"/>

The Live property explorer shows a Local definition, which in my opinion is not present, is also crossed out.

The GroupSizeDefinitions which are actually being used are under the heading Coercion.

enter image description here

I'm afraid that I can't explain that, but maybe somebody else can.

Upvotes: 0

Related Questions