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>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
MarkupExtentionthat 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.DependencyObjectand 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.