开发者

Bind List of UControls to a Controls Children property?

I have got an开发者_Python百科 ObservableCollection<Button> 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜