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
100
Binding to a Collection of Objects which have an Array of "Properties"
posted

Hello,

I've been searching for an answer to this question and can't find one. I've tried all sorts of things but would appreciate some help now please.

[For the sake of simplicity, I've mapped my problem onto the below example]

I have an ObservableCollection<Person> called Persons.

A Person has a property called Data. Datais just a String[

So an example of Data would be {"Michelle", "Blue Eyes", "Blonde Hair", "Petite Build"}.

Every person has exactly the same number of strings in their Features string[.

What I need to do is bind to Persons, and have it show one Person per line, and Data[0] in column 0, Data[1] in column 1etc

Is this even possible?

My current alternative involves dynamically generating the Person class such that it has properties for each of the items in Data

e.g. string Person.D1 { get { return Data[1]; }  }

This would allow  me to bind to D1, D2, D3 etc in the Grid.

There must be a better way?

Thanks,

Lee

Parents
No Data
Reply
  • 6867
    Verified Answer
    posted

    Hi Lee,

    You can use UnboundFields to do this:

    <igDP:FieldLayout>
      <igDP:FieldLayout.Fields>
        <igDP:Field Name="Data" IsExpandable="False" Visibility="Collapsed" />
        <igDP:UnboundField Label="Value 1" BindingPath="Data[0]" />
        <igDP:UnboundField Label="Value 2" BindingPath="Data[1]" />
        <igDP:UnboundField Label="Value 3" BindingPath="Data[2]" />
      </igDP:FieldLayout.Fields>
    </igDP:FieldLayout>

Children