Control element level by tape sizes using WPF tape (for .NET 4) and RibbonControlSizeDefinition

According to the MSDN documentation , the ribbon: RibbonControlSizeDefinition can be used to control the size of an element in the WPF ribbon by setting the ControlSizeDefinition Property. Has anyone had success using this property? I believe that it is completely ignored. I initially installed it using data binding, but also tried using the code behind the file.

This question is similar, but in one of the comments he correctly noted that the OP used RibbonControlGroup and therefore saw the expected behavior.

I understand that it is usually best to allow the tape to do this on its own with regard to calibration. Unfortunately, this is not an option for this project.

I have listed the part of my XAML code that does not work below.

    <ribbon:RibbonTab Header="MyTab">
        <ribbon:RibbonGroup Header="MyGroup">
            <ribbon:RibbonButton Label="My big button" Name="BigButton"
                                 LargeImageSource="Images\Ribbon\assignments_duties_a2k_32.png"
                                 SmallImageSource="Images\Ribbon\assignments_duties_a2k_16.png">
                <ribbon:RibbonButton.ControlSizeDefinition>
                    <ribbon:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True" />
                </ribbon:RibbonButton.ControlSizeDefinition>
            </ribbon:RibbonButton>
            <ribbon:RibbonButton Label="My little button" Name="SmallButton"
                                 LargeImageSource="Images\Ribbon\assignments_duties_a2k_32.png"
                                 SmallImageSource="Images\Ribbon\assignments_duties_a2k_16.png">
                <ribbon:RibbonButton.ControlSizeDefinition>
                    <ribbon:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True" />
                </ribbon:RibbonButton.ControlSizeDefinition>
            </ribbon:RibbonButton>
        </ribbon:RibbonGroup>
    </ribbon:RibbonTab>
+5
source share
1 answer

After some experimentation, I have a workaround. I tried to use the size of the group level instead of determining the size of the element using the ribbon: RibbonGroup.GroupSizeDefinitions property. This works as documented. In addition, to set element-level properties, just set this for an empty RibbonGroupSizeDefinition. My code above becomes:

<ribbon:RibbonTab Header="MyTab">
     <ribbon:RibbonGroup Header="MyGroup">

            <ribbon:RibbonGroup.GroupSizeDefinitions>
                <ribbon:RibbonGroupSizeDefinition>
                </ribbon:RibbonGroupSizeDefinition>
            </ribbon:RibbonGroup.GroupSizeDefinitions>

         <ribbon:RibbonButton Label="My big button" Name="BigButton"                                  LargeImageSource="Images\Ribbon\assignments_duties_a2k_32.png"                                  SmallImageSource="Images\Ribbon\assignments_duties_a2k_16.png">
                <ribbon:RibbonButton.ControlSizeDefinition>
                    <ribbon:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True" />
                </ribbon:RibbonButton.ControlSizeDefinition>
         </ribbon:RibbonButton>
         <ribbon:RibbonButton Label="My little button" Name="SmallButton"                                  LargeImageSource="Images\Ribbon\assignments_duties_a2k_32.png"                                  SmallImageSource="Images\Ribbon\assignments_duties_a2k_16.png">
                <ribbon:RibbonButton.ControlSizeDefinition>
                    <ribbon:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True" />
                </ribbon:RibbonButton.ControlSizeDefinition>
         </ribbon:RibbonButton>
     </ribbon:RibbonGroup>
 </ribbon:RibbonTab> 
+5
source

All Articles