I tried the following and get "Object reference not set to an instance of an object." when I try to add the first item (a string) to the combobox (there is a value in s at the time). What's the correct way to do this:
XAML snippet:
<igRibbon:RibbonTabItem Header="Skins"> <igRibbon:RibbonGroup Id="skins" Caption="Skins" > <igRibbon:ComboEditorTool Id="cetSkins" x:Name="cetSkins" DropDownResizeMode="VerticalOnly" IsEditable="False"SelectedItemChanged="cetSkins_SelectedItemChanged"/> </igRibbon:RibbonGroup>
<igRibbon:RibbonGroup Id="skins" Caption="Skins" >
<igRibbon:ComboEditorTool
Id="cetSkins"
x:Name="cetSkins"
DropDownResizeMode="VerticalOnly"
IsEditable="False"
</igRibbon:RibbonGroup>
Code:
public Window1() { InitializeComponent();string[ f = Directory.GetFiles("skins", "skin*.xaml"); foreach (string s in f) this.cetSkins.ComboBox.Items.Add(s);
{
InitializeComponent();
foreach (string s in f)
this.cetSkins.ComboBox.Items.Add(s);
I've also tried putting my code in as separate Window_Loaded event but that fails the same way.
Thanks!
Glenn L
Hi Glenn -
The ComboEditorTool (as well as the XamComboEditor control from which it is derived) get their data from a special object called ComboBoxItemsProvider. The ComboBoxItemsProvider (which exposes an Items property as well as an ItemsSource property) is hooked up to the ComboEditorTool by assigning an instance of it to the ItemsProvider property of the ComboEditorTool.
WIth this in mind you would modify your code to create a ComboBoxItemsProvider, add the strings to the Items proeprty of the ComboBoxItemsProvider and then set the ItemsProvider property of the ComboEditorTool to the ComboBoxItemsProvider instance.
Note: A ComboBoxItemsProvider instance can be assigned to multiple ComboEditorTool instances for efficiency purposes if the drop down items are the same across those ComboEditorTools. The ComboBoxItemsProvider object is the one that manages the items and binding to the items source.
Joe Modica
I have a similar problem, being that I can't figure out how to bind commands to the items in a comboEditorTool nor in a MenuTool (in the XamRibbon more specifically). Can someone please give an example on how to:
Thank you
Serge