ViewModel
I have a property of type Member called KeyMember. The 'Member' type has an ObservableCollection called Addresses. The Address is composed of two strings - street and postcode .
View
I have a ListBox whose item source need to be set to ViewModels's KeyMember property and it should display the Street of all the Past Addresses in the Address collection.
Question
My ViewModel and View relationship is established properly.
I am able to write a data template for the above simple case as below
<ListBox ItemsSource="{Binding KeyMember.Addresses}">
<ListBox.ItemTemplate>
<DataTemplate DataType="Address">
<TextBlock Text="{Binding Street}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I am curios to know how to write the DataTemplate if I change KeyMember from type Member to ObservableCollection< Member > assuming that the collection has only one element. I am not sure whether this is a valid scenrio and it's implementation feasibility.
PS: I know that for multiple elements in collection, I will have to implement the Master-Detail pattern/scenario. I am looking into this at the moment.