I am somewhat new to WPF and Data Binding, it seems very powerful. I’m wondering if there’s a way to have a set of labels, and have there Content property all binded to a different index in array of strings. So then as the array is updated, the labels automatically change too.
The xaml syntax is still a bit foreign to me and I haven’t been able to get it to work.
If this is a dynamic set of labels, then you may be better off using an
ItemsControl, and changing itsItemTemplateto display a label for each item in the collection that it is bound to (a collection of strings in your case).Something like:
As Bojin mentions, if you wish your UI to update if strings are added/removed from the collection, then use an
ObservableCollectionfor theMyLabelStringsproperty.