I try to bind my XamComboEditor's DataSource of my xamDataGrid and the binding doesn't work. The field is a lookup, where the user must pick a value from the combobox. The list contains Description and the bound field is called DrugId. DrugList.Model contains a Id and a Description. Here's my code:
<igDP:UnboundField Label="{x:Static cow:HealthResources.Drug}" Row="1" Column="0" BindingMode="TwoWay" BindingPath="DrugId">
<igDP:UnboundField.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" >
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="ItemsSource" Value="{Binding DrugList.Model}" />
<Setter Property="DisplayMemberPath" Value="Description" />
<Setter Property="ValuePath" Value="Id" />
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:UnboundField.Settings>
</igDP:UnboundField>
This gives me the error in VS output window: BindingExpression path error: 'DrugList' property not found on 'object' ''TemplateDataRecord' (HashCode=3700058)'. BindingExpression:Path=DrugList.Model; DataItem='TemplateDataRecord' (HashCode=3700058); target element is 'XamComboEditor' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')
A simple combobox like this show the items list correctly, so the problem lies only in the way I have to set the binding:
<ComboBox Width="100" DisplayMemberPath="Description" ItemsSource="{Binding DrugList.Model}" </ComboBox>
How should I set the binding to fill that xamComboEditor?
Fred.
Hello Fred,
The binding looks okay, but the exception shows that this property cannot be found. I think the problem is in the relative source. It defaults to the record and not to the underlying data item. Try using a binding expression like this:
DataItem.DrugList.Model to target the business object.
With DataItem.DrugList.Model, it now complains that DrugList is not part of my object that is binded to the grid's DataSource property. 'DrugList' property not found on 'object' ''AnimalTreatmentEntity' (HashCode=4154422)'.
That's a step forward, but my DrugList is not related in any way to the object I use as a DataSource. What else can I try?