views:

7

answers:

1

Hello,

I have got an ObservableCollection buttonList; (this can be any other control: Textbox, Textblock or even a UserControl).

I want to bind this List via DataBinding to a parent control (lets say a Grid or a WrapPanel,...) Is this somehow possible? Children property is read only. I do not want to do this in the program code -> Dont iterate through the list and add every item to the children property. I want to BIND the List to a parent control -> the View is automatically updated, every time I add a new Item to the List.

Any Ideas?

A: 

Use ItemsControl, and bind your collection to ItemsSource.

And don't forget to read Dr. WPF's articles: ItemsControl: A to Z. This is second time I'm mentioning this blog today here, but he really-really deserves to be mentioned in every post related to collection of items and bindings :).

Cheers, Anvaka.

Anvaka