WPF RibbonComboBox items listed vertically

I am working on some XAML where I have a RibbonComboBox:

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

When it is displayed, it displays the elements horizontally, and not vertically, as I expected: enter image description here

How to style it to place elements vertically?

+4
source share
2 answers

Try setting the RibbonGallery.MaxColumnCountvalue to 1:

<RibbonGallery ... MaxColumnCount="1">
+5
source

Set ItemsPanel in style and set orientation = vertically

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

Hope this helps.

+3
source

All Articles