Search code examples
c#wpfcomboboxribbon

RibbonComboBox doesn't display selected item


Very simple program. Maybe too simple? XMAL:

<RibbonComboBox x:Name="cbxRibbonCommsGroupBaud"  LargeImageSource="Resource/Cheetah.png">
   <RibbonGallery Name="RBaudGGallery" SelectionChanged="RBaudGGallery_OnSelectionChanged">
       <RibbonGalleryCategory Name="RBaudGGalleryC" ItemsSource="{Binding}"></RibbonGalleryCategory>
   </RibbonGallery>
</RibbonComboBox>

The code behind:

private int[] baudRateList = { 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600 };
cbxRibbonCommsGroupBaud.Items.Clear();
cbxRibbonCommsGroupBaud.ItemsSource = baudRateList;

When I run the program, the items are in the combobox drop down but when I select the item, it doesn't stay and the box appears empty. Also, RBaudGGallery_OnSelectionChanged is never called. So I'm missing something but have no clue what since other combo boxes are working just fine that aren't in the ribbon. I'm using the Reference of System.Windows.Controls.Ribbon.


Solution

  • Why don't you have a SelectedItem binding set?

    SelectedItem = {Binding mySelectedBaud}
    

    How to databind SelectedItem of RibbonComboBox