垂直列出的WPF RibbonComboBox项

时间:2014-01-03 16:28:02

标签: c# wpf ribbon

我正在开发一些我有一个RibbonComboBox的XAML:

<RibbonComboBox SelectionBoxWidth="150" Grid.Row="0">
    <RibbonGallery SelectedItem="{Binding SelectedUtilityRun, Mode=TwoWay}">
        <RibbonGalleryCategory ItemsSource="{Binding UtilityRunLabels}" />
    </RibbonGallery>
</RibbonComboBox>

当它显示时,它按照我的预期水平而不是垂直显示项目: enter image description here

如何设置样式以垂直放置项目?

2 个答案:

答案 0 :(得分:5)

尝试将RibbonGallery.MaxColumnCount设置为1:

<RibbonGallery ... MaxColumnCount="1">

答案 1 :(得分:3)

在样式中设置ItemsPanel并设置方向=垂直

<Style TargetType="RibbonComboBox">
<Setter Property="ItemsPanel">
<Setter.Value>
  <ItemsPanelTemplate>
    <StackPanel Orientation="Vertical"
                VerticalAlignment="Center"
                HorizontalAlignment="Center"/>
  </ItemsPanelTemplate>
</Setter.Value>

我希望这会有所帮助。