I have described my problems with binding the SelectedItem of the RibbonComboBox. Another very ugly issue arises when trying to style this control.
Starting with the unstyled ComboBox from the post mentioned above:
<r:RibbonComboBox >
<r:RibbonGallery SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
<r:RibbonGalleryCategory ItemsSource="{Binding Controls}" DisplayMemberPath="Caption" />
</r:RibbonGallery>
</r:RibbonComboBox>
I get the expected result:
But when applying a style with the help of Microsoft Blend (Preview for VS 2012), Object | Edit Style | Edit a Copy... (copying only the Template, with Blend or Visual Studio, has the same effect):
The selected item will no longer be displayed correctly - instead of the DisplayMemberPath property, the type name is shown. Items in the dropdown are still correct. Note that I did not yet change the style in any way, it is the default style/template that gets extracted that will produce this issue.
<r:RibbonComboBox Style="{DynamicResource RibbonComboBoxStyle1}" >
I also had trouble to style my dropdown items (mainly wanted to change the mouseover background cornerradius), because the ItemContainerStyle for the RibbonComboBox will have target type RibbonMenuItem and does not seem to have an effect on the actual RibbonGalleryItems.
- How to fix the RibbonComboBox style?
- How can I get to the RibbonGalleryItem style by way of Blend/VS?
You may want to take a look at JetBrains dotPeek decompiler.
One of its features is:
In addition, I just finished to edit visual RibbonCombobox and its relative controls by using the decompiler mentioned above, which decompiled the entire Ribbon library including original Microsoft .XAML themes.
Currently, I have solved this issue by extracting the default RibbonComboBox style directly from RibbonControlsLibrary.dll (Resources/RibbonControlsLibrary.g.resources/themes/generic.baml) with ILSpy.
This is tedious work, because the style references other StaticResources in the same file, so you need to find and extract those, too.
The same applies to the RibbonGalleryItem style, it can be extracted like this, but I would prefer a "cleaner" solution involving Blend or Visual Studio.