I am trying to bind a object collection to a Telerik TreeView control. My object structure would somehow look like:
Item 1.1
- Item 1.1.1
- Item 1.2.1
- Item 1.2.2
- Item 1.1.2
...
Item n.1
- Item n.1.1
- Item n.2.1
- Item n.3.1
All these object have a common bool property, i.e. isBindable. I want to bind this collection to my TreeView control, but the control should only bind the object if its property isBindable = true.
I don’t want to loop through the whole collection and remove one-by-one based on isBindable before doing an ItemSource to the control.
Any better idea how can I achieve that, maybe with LINQ?
Thanks,
Bhaskar
You can try to achieve this using recursion. You would need a single
foreachloop though. Please see the below method. Just pass your collection to this method and see if it gets filtered.