Binding of indexed property

Posted by: gennadiy_lenivenko on 29 December 2019, 9:36 pm EST

    • Post Options:
    • Link

    Posted 29 December 2019, 9:36 pm EST

    I am trying to bind child collection to FlexGrid e.g.

    … public class MyParentClass { public string Id {get;set;} public List Children {get;} }

    public class MyChildClass { public string Name {get;set;} } … for (int i = 0; i < 3; i++) { int j = i; <GridColumn Binding=@(“Children[”+j+“].Name”) Header=@(“Name” + j) /> } …

    But I cannot see anything except data in the first column Is this limitation of control or I made a mistake? Thank you

  • Posted 30 December 2019, 1:49 pm EST

    Hi, The code snippet provided by you seems OK and it should work. We tried the same and it works for us with the build version: 3.1.20193.434.

    Please refer to the following code and the attached sample for reference.

    <FlexGrid ItemsSource="TreeItems" AutoGenerateColumns="false">
            <GridColumn Binding="ID"></GridColumn>
            <GridColumn Binding="Name"></GridColumn>
            @for (int i = 0; i < TreeItems[0].Children.Count; i++)
                <GridColumn Binding=@("Children["+i+"].Name") Header=@("Child"+(i+1)+" Name")></GridColumn>
        List<Tree> TreeItems = Tree.GetData(5);

    Just for information, assigning i to variable j is not useful in this case. You may avoid the line of code.

    Hope it helps!

    Regards, Manish Gupta

  • Posted 3 January 2020, 6:24 am EST

    Thank you, Mr. Manish,

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels