【问题标题】:Vertically center RibbonComboBox in RibbonGroup (in WPF)RibbonGroup 中的 RibbonComboBox 垂直居中(在 WPF 中)
【发布时间】:2018-11-25 07:07:47
【问题描述】:

我想知道是否有可能在 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>

感谢您的帮助!

【问题讨论】:

    标签: wpf vertical-alignment ribbon-control


    【解决方案1】:

    实现这一点的一种方法是添加一个高度很大的网格并将垂直对齐设置为居中:

    <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>
    

    【讨论】:

    • 我已经尝试支持您的答案,但系统说(目前)我没有足够的声誉。但我会再试一次,只要我的声望级别足够高。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-09
    • 2013-10-15
    • 2014-05-29
    • 1970-01-01
    • 1970-01-01
    • 2012-12-29
    • 2011-07-07
    相关资源
    最近更新 更多