在 RibbonGroup 中垂直居中 RibbonComboBox(在 WPF 中)
Vertically center RibbonComboBox in RibbonGroup (in WPF)
我想知道是否可以在不设置边距的情况下将 RibbonComboBox 在 RibbonGroup 中垂直居中。
我尝试使用 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>
我想知道是否可以在不设置边距的情况下将 RibbonComboBox 在 RibbonGroup 中垂直居中。 我尝试使用 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>