Databinding to a property which is a collection.
-
I found no answer to this problem yet. I have a Collection with customer data. One of the properties of the customer class is a collection of addresses. I can bind these collection of addresses to a combobox or listbox with the ItemsSource property. But what I really want to do is bind some of these addresses to different textboxes. ex:
TextBox1.Text="{binding Customer.Addresses.Address[0]}"
TextBox2.Text="{binding Customer.Addresses.Address[1]}"
...I hope this is possible... Also is it possible to sort or filter in this binding scenario? Many thanks for your thoughts.
-
I found no answer to this problem yet. I have a Collection with customer data. One of the properties of the customer class is a collection of addresses. I can bind these collection of addresses to a combobox or listbox with the ItemsSource property. But what I really want to do is bind some of these addresses to different textboxes. ex:
TextBox1.Text="{binding Customer.Addresses.Address[0]}"
TextBox2.Text="{binding Customer.Addresses.Address[1]}"
...I hope this is possible... Also is it possible to sort or filter in this binding scenario? Many thanks for your thoughts.
ddecoy wrote:
TextBox1.Text="{binding Customer.Addresses.Address[0]}" TextBox2.Text="{binding Customer.Addresses.Address[1]}"
I suspect you mean this:
<TextBox Text="{Binding Customer.Addresses[0].Address}" />
<TextBox Text="{binding Customer.Addresses[1].Address}" />"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
ddecoy wrote:
TextBox1.Text="{binding Customer.Addresses.Address[0]}" TextBox2.Text="{binding Customer.Addresses.Address[1]}"
I suspect you mean this:
<TextBox Text="{Binding Customer.Addresses[0].Address}" />
<TextBox Text="{binding Customer.Addresses[1].Address}" />"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.