wpf - RibbonGroup 中的 RibbonComboBox 垂直居中(在 WPF 中)
问题描述
我想知道是否有可能在 RibbonGroup 中将 RibbonComboBox 垂直居中而不设置边距。我尝试使用 VerticalAlignment 和 VerticalContentAlignment,但不幸的是这不起作用。
这是它现在的样子:
这就是它的样子(请不要使用边距设置):
这是我目前的代码:
<RibbonTab Name="RibbonTab_Test" Header="Test">
<RibbonGroup Name="RibbonGroup_Test" Header="New Test">
<RibbonComboBox Name="RibbonComboBox_Test" IsEditable="False" SmallImageSource="img/verschreibungspflichtige-pillendose-16.png">
<RibbonGallery SelectedValue="This Test-Text is to long" SelectedValuePath="Content" MaxColumnCount="1">
<RibbonGalleryCategory>
<RibbonGalleryItem Content="This Test-Text is to long"/>
<RibbonGalleryItem Content="Test 1"/>
<RibbonGalleryItem Content="Test 2"/>
</RibbonGalleryCategory>
</RibbonGallery>
</RibbonComboBox>
</RibbonGroup>
</RibbonTab>
谢谢您的帮助!
解决方案
实现此目的的一种方法是添加一个高度非常大的网格并将垂直对齐设置为居中:
<RibbonGroup Name="RibbonGroup_Test" Header="New Test">
<Grid VerticalAlignment="Center" MinHeight="120">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<RibbonComboBox Name="RibbonComboBox_Test" IsEditable="False" VerticalAlignment="Center" SmallImageSource="img/verschreibungspflichtige-pillendose-16.png">
<RibbonGallery SelectedValue="This Test-Text is to long" SelectedValuePath="Content" MaxColumnCount="1" >
<RibbonGalleryCategory>
<RibbonGalleryItem Content="This Test-Text is to long"/>
<RibbonGalleryItem Content="Test 1"/>
<RibbonGalleryItem Content="Test 2"/>
</RibbonGalleryCategory>
</RibbonGallery>
</RibbonComboBox>
</Grid>
</RibbonGroup>
推荐阅读
- javascript - 它一直说“必须转义特殊字符:<”这是什么意思?
- python - 我的 pos_tag 遍历每个字母,我需要将它应用于整个单词
- python-3.x - 从一列中具有相同值但在另一列中具有不同值的行中选择
- sql - SQL Server 2014 中的函数 STRING_SPLIT
- visual-c++ - 寻找材料以了解如何使用 Visual C++ 开发 UWP 应用程序
- javascript - 何使用 typescript 函数作为 JavaScript 库的回调
- shell - 在Shell脚本中使用双双引号在字符串之间提取数据
- tensorflow - 如何获取 tensorflow.data.Dataset 的行数、列数/维度?
- coldfusion - Lucee 中的图表
- android - 两天后 Google Play 应用总安装量仍为 0+