I'm developing an app in .NET 4.5.1 WPF/C#. I have added the Microsoft RibbonBar to the main window. On it, I have a RibbonComboBox which I populate at runtime with labels. Wen the user selects an item from the RibbonComboBox, however, it is not firing the SelectionChanged event.
Here is the code that populates the RibbonComboBox:
private void PopulateRibbonComboBox() { Label label; label = new Label(); label.Content = "a"; ribbonComboBox.Items.Add(label); label = new Label(); label.Content = "b"; ribbonComboBox.Items.Add(label); label = new Label(); label.Content = "c"; ribbonComboBox.Items.Add(label); }
Here is the XAML for the RibbonBar:
<Ribbon><RibbonTab Header="Tab"><RibbonGroup Header="Group"><RibbonComboBox x:Name="ribbonComboBox" Label="Select an item:"><RibbonGallery Name="ribbonGallery" SelectionChanged="ribbonGallery_SelectionChanged"></RibbonGallery></RibbonComboBox></RibbonGroup></RibbonTab></Ribbon>
And finally, the C# code that handles the SelectionChanged event:
private void mapTypesRibbonGallery_SelectionChanged(object sender, RoutedPropertyChangedEventArgs<object> e) { RibbonGallery source = e.OriginalSource as RibbonGallery; if (source == null) return; Label selectedLabel = (Label)source; }
However, when I run the program and select an item from the RibbonComboBox, the SelectionChanged event doesn't fire. Any ideas where I'm going wrong? I'm quite new to WPF/XAML and very new to the RibbonBar.
Thank you...
Fabricio Rodriguez Pretoria, South Africa