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
165
xamdatagrid combobox binding
posted

I have a collection of U.S States with their respective counties that I would like to display in the xamdatagrid.  I think it's a complex binding but not sure how to do it.  The state class looks like:  int id, string StateName, List<Counties>.  Counties looks like: int id, string countyName. The state collection is returned with its county collection from the database.  In the xamdatagrid I would like to display the collection of states, and their associated counties.  

<igDp:FieldLayout.Fields>
    <igDp:ComboBoxField Name="StateCd" ItemsSource="{Binding Source={StaticResource StateCodes}}"
        DisplayMemberPath="LongName" ValuePath="StateId" Label="State" LimitToList="True" AllowResize="True" Width="Auto" />


     <igDp:ComboBoxField Name="CountyId" ItemsSource="{Binding Source={StateCodes.Counties}}"
       DisplayMemberPath="LongName" ValuePath="Id" Label="County" LimitToList="True" AllowResize="True" Width="Auto" />


    <igDp:TextField Name="Description" Label="Description" AllowResize="True" Width="Auto" IsReadOnly="True"/>
</igDp:FieldLayout.Fields>

The idea is to have the appropriate list of counties displayed in the drop downlistbox for the selected state for each row in the datagrid.

How do I bind the itemsSource of the county to the complex property of the state.counties collection?

Parents
No Data
Reply
  • 34430
    Offline posted

    Hello Kevin,

    The reason that your binding is not currently working in this case is because you cannot directly bind the properties of Field objects in the XamDataGrid. The reason for this is because they are not visual objects – that is, they are not part of the visual tree of the WPF application, and as such direct binding like you are currently trying to do is not a supported action.

    In order to bind the ItemsSource of the ComboBoxField in this case, my best recommendation would be to utilize a CellBinding, which is a sort of binding proxy that we have put into place to allow binding of Field properties to data item properties. You can read further about the CellBinding here: https://www.infragistics.com/help/wpf/xamdatagrid-binding-cell-settings-data-item-properties.

    Please let me know if you have any other questions or concerns on this matter.

Children
No Data