Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
560
My XamComboEditor ItemsSource binding won't work.
posted

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.

  • 69686
    posted

    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.