I'm trying to figure out how to bind the Ribbons Conbobox editor to an object. I have the ItemsSource working ok, but I can't seem to figure out how to get the selecteditem to bind to the class.
<igRibbon:ComboEditorTool Caption="Table" Name="Table" ItemsSource="{Binding Table.Tables}" DisplayMemberPath="Description" ValuePath="ResourceId"></igRibbon:ComboEditorTool>
The RibbonGroup's DataContext is being set in code to a class and in the class is Class.Table and in Class.Table is the ResourceID. I've tried various combinations in the ValuePath like Table.ResourceID and others. Should I be using something else other than ValuePath? I even tried hard coding to set the SelectedItem to the Table class but was getting messages about the combo needed to be in edit mode.
Thanks
Hi,
if you need to bind the SelectedItem property just try with SelectedItem="{Binding Table.ResourceID}". If that doesn't help you please show us the Class you are binding with.
Regards.
I just tried binding to SelectedItem but that doesn't seem to work either. I probably have at least 10 combos in the ribbon where I will need to do this with objects and 3-4 combos using enums. I included the classes and some code in a separate email.
I'm also trying to figure out how to make the texttool read only so I can display some information via binding.
Thanks,
Why not just define a type class for your enum (sample below), spin up a generic list collection by iterating through your enum, adding your enum type class for each enum, and assign that list object to your combo box? If you don't know how to iterate an enum, Google it and there are many examples. Once you have your populated list, assign the list to the ItemSource of the combo box and use a SelectedEnuMitem object for the selected item.
****************************************
public class MyEnumItem
public MyEnumItem(string myEnumText, int myEnumValue;
{
MyEnumText = myEnumText;
MyEnumValue = myEnumValue;
}
public string MyEnumText {get; set;}
public string MyEnumValue {get; set;}
Hope this helps.
I'm using enums for some combos and Lists<object> for others. Using the suggested SelectedItem={binding xxxx} it now does bind to the class's property on 4 combos I've tried using enums so any change in the combo selection sets the property in the class. For now I'm doing this (see below) so I can have user friendly selections and the enums line up with the order in the combo.
<igRibbon:ComboEditorTool Caption="Starting Point" Name="SeatingStartingPoint" HorizontalAlignment="Right" SelectedIndex="{Binding SeatingStartingPoint}">
<igRibbon:ComboEditorTool.ItemsProvider><igEditors:ComboBoxItemsProvider >
<igEditors:ComboBoxDataItem DisplayText="Top Left"/>
<igEditors:ComboBoxDataItem DisplayText ="Top Right"/>
<igEditors:ComboBoxDataItem DisplayText="Bottom Right"/>
<igEditors:ComboBoxDataItem DisplayText="Bottom Left"/>
</igEditors:ComboBoxItemsProvider></igRibbon:ComboEditorTool.ItemsProvider>
</igRibbon:ComboEditorTool>
The current problem is the combo is not defaulting to the what is in the class's property. Not sure if this might be because of how I'm using it. I have another combo that the user uses to select 1 of 10 items (10 similar but different classes all based off the same class). In the combo's SelectedItemChanged event, I set the my 5 RibbonGroups DataContext with appropriate class selected. The enum combos aren't displaying the property they are bound to. Any TextEditor and MaskedEditor tools in the ribbongroups work fine. If I set a break point on the Get of the property, it is being called right after the DataContext is set so that part seems to work, we are just not seeing the info in the combo. I have about 20 combos in the ribbon that I need to get working.
Any suggestions? Once I get the Enums working, I'll move on to the List<object>.
You said you were using enum values, so you can bind the SelectedIndex to a property in your code behind or ViewModel and do waht you want in the property setter or getter. If you are binding to a collection that implements iEnumerable, then you can bind the SelectedItem to an object in that collection. You can use either, it depends on how you want to do it, In your case, you are not using a collection bound to the combo box ItemSource from what you shared.
I thought SelectedIndex is a number, will it allow to binding to a class? Is there any writeup on how to use the combo, with binding, in the Ribbon? I have been through the docs online and in the infragistics folder on the PC, but didn't see anything except for something for the comboeditor when it is not used in the ribbon.
I beleive it is SelectedIndex you want to bind to, not SelectedItem.