Is it possible to use binding to add objects to a XAML collection.
something like
<x:Array Type="sys:Int32">
<Binding Source="obj", Path="Prop1"/>
<Binding Source="obj", Path="Prop2"/>
</x:Array>
Is it possible to use binding to add objects to a XAML collection.
something like
<x:Array Type="sys:Int32">
<Binding Source="obj", Path="Prop1"/>
<Binding Source="obj", Path="Prop2"/>
</x:Array>
No, the target of a data binding must be a dependency property and an element of a collection is not a property.
I can think of two workarounds, but both are ugly and I wouldn't use any of them:
MarkupExtention
that will create a collection with whatever you want, you can even create one that create a collection from bindings, but the syntax will be very strange and the collection content won't be updated from the binding source.DependencyObject
and have dependecy properties for elements in teh collection (properties e0, e1, e2 ... that will update the contant of the collection when set).I would try to find a way to accomplish what you want to do without filling a collection from data binding.