根据the MSDN documentation,功能区:RibbonControlSizeDefinition可用于通过设置ControlSizeDefinition属性来控制WPF功能区上项目的大小。有没有人使用这个属性有什么成功?我发现它完全被忽略了。我最初使用数据绑定设置它,但也尝试使用代码隐藏文件。
This question是类似的,但在其中一条评论中正确地指出OP使用了RibbonControlGroup,因此看到了预期的行为。
我知道通常最好让功能区在尺寸调整方面做自己的事情。可悲的是,这不是这个项目的选择。
我列出了我的XAML代码中不起作用的部分。
<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>
答案 0 :(得分:6)
经过一些实验,我有一个解决方法。我尝试使用功能区:RibbonGroup.GroupSizeDefinitions属性,使用组级别大小而不是项目级别大小。这有助于记录。此外,将此设置为空RibbonGroupSizeDefinition足以使项级属性工作。我上面的代码变成了:
<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>