5

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 displays, it shows the items horizontally rather than vertically as I expected: enter image description here

How do I style it to place the items vertically?

Walter Williams
  • 944
  • 3
  • 11
  • 25
  • Can I ask where you got the documentation about how to use the RibbonComboBox? I can't seem to get anything to work. Also, do you happen to know if there's any way to manually populate it from code? (I posted my own question on this but got no answer.) – Jonathan Wood Jul 05 '16 at 21:56
  • Sorry, I don't remember where I got it beyond MSDN. I don't know how you'd populate it from code using the code behind of the control. We use MVVM with all our WPF work. – Walter Williams Jul 06 '16 at 16:54

2 Answers2

6

Try setting RibbonGallery.MaxColumnCount to 1:

<RibbonGallery ... MaxColumnCount="1">
dkozl
  • 32,814
  • 8
  • 87
  • 89
3

Set ItemsPanel in Style and Set Orientation=Vertical

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

I hope this will help.

yo chauhan
  • 12,079
  • 4
  • 39
  • 58
  • This did not work. It created a stack panel within the item list that was centered horizontally; the items within the stack panel were horizontally laid out. Unfortunately I can't post a picture here. – Walter Williams Jan 03 '14 at 17:32
  • Sorry If it havent worked . I havent ever used or worked with Ribbon Controls .But this is the way I set ItemPanel in Itemscontrol – yo chauhan Jan 03 '14 at 17:35