I'm trying to bind a xamComboBox to a xamDataGrid. The datagrid is bound to an collection objects, and one of the properties on each of those objects is a collection of items that should be in the combobox for that row (in other words each row has a unique combo box.
Hints?
Something like this should work for you:
<igDP:Field Width="Auto" Name="ItemName" Label="{x:Static local:ModuleStrings.ItemName}"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" > <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding Path=DataItem.MyListOfItems}" /> <Setter Property="IsEditable" Value="True" /> <Setter Property="DisplayMemberPath" Value="ItemName" /> <Setter Property="ValuePath" Value="ItemName" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings></igDP:Field>
OK, I figured out that issue. It was a datatype issue. I had a decimal in the grid, but the itemsource value was an Integer.
I'd still really love to get this editing happenning in the grid...
Since I can't get the combobox to to display in the grid and be able its itemsource to a property collection of the selected item I figured I'd just put a combo box outside the grid and create a detail editor.
So I have this grid which can have 1 or more coverages in it. For each coverage the user can select a coverage amount from a list. Each coverage can have its own unique list of coverage amounts. I've been able to bind the combo box to the grid's active record in order to populate the items in the combo box, and I've been able to bind the value to the value from the grid so the propery item is selected. The problem occurs when I change the the selection in the combobox. It isn't updating the grid, and it's not calling the poperty setter for the BenefitAmount property.
I've tried both Infragistics and Microsoft combo boxes and neither worked. I was able to bind a text box and when I update the value in the text box and lose focus it updates the grid, calls the property setter, and just to rub salt in the wound it updates the combobox.
<
e:XamComboEditor DataContext="{Binding ElementName=grdCoverage, Path=ActiveRecord.DataItem}" ItemsSource="{Binding Path=BenefitAmountOptions}" DisplayMemberPath="PlanProvisionValueName" ValuePath="PlanProvisionValueID" Value="{Binding Path=BenefitAmount, Mode=TwoWay}" />
I tried copying the feature browser before I posted. The problem is the sample shows how to bind the combobox itemssource to a static resource, and I need the source for the items in the combo box to come from a collection on the object that is the DataRecord.
Each row in the grid could have a different list of items in it's combobox.
It looks like all you need to do is change the EditorStyle/EditorType property of the Field to XamComboEditor. This way the XamDataGrid will create a Combo editors for the values of the cells in that field. You can see examples of that in the XamFeatureBrowser as well.