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
410
Databinding with Enumerations/Lists
posted

Hi,

I'm trying to create a grid to a data source of the following kind:

ObservableCollection<MyRow> mydata;

where MyRow contains the following properties:

String name;

String info;

List <SpecialData> data;

And SpecialData  consists of

String info1;

String info2;

 

Now my grid should have name and info as the two first columns and these are fixed. This works fine. The data list can contain any number of SpecialData objects, but for one mydata object it is constant.

Third and forth column should be info1 and info2 of the first data element, fifth and sixth column should be info1 and info2 of the second data element, etc..

for (int i = 0; i < data.Count; i++)

{

...

field = new Field(string.Format( "data[{0}].info1" , i )){...};

...

field = new Field(string.Format( "data[{0}].info2" , i )){...};

...

}

This creates the columns and shows a header but the cells contain no value.

I change "data[0].info1" into "name" everything works fine.

Is it not possible to attach any indirection to a field? Does it always have to be simple property?

If so, is there any workaround for my situation?

 

Thanks,

 

Bettina

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello Bettina,

     

    It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. So I have been looking through your post and I created a sample project for you. Basically I set the AutoGenerateFields to False and define the FieldLayout explicitly. For the child elements of each Record I used UnboundFields and bind them to the SpecialData List.

     

    Feel free to write me if you have further questions.

    XamDataGridHierarchicalDataInOneLayout.zip
Children
No Data