I've two ObservableCollection
that I've to display in the same WPF ListBox
(or similar, I'm quite open.
So in my ViewModel, I've
public ObservableCollection<MySubViewModel> ListA {get;set;}
public ObservableCollection<MySubViewModel> ListB {get;set;}
I know that I could create a new Property which combines the 2 collections, but the thing is:
- Those 2 collections will have new/removed elements
- I always need to have the object of the collection 1 to be on the top, and the collection 2 on the bottom
- I was thinking/hopping/praying that there was a solution
I already tried to use `CompositeCollection, but I don't have the feeling this works with the Observable part?
<ListBox>
<ListBox.ItemTemplate>
<TextBlock Margin="5" Text="{Binding Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsSource>
<CompositeCollection>
<CollectionContainer Collection="{Binding ListA }" />
<CollectionContainer Collection="{Binding ListB }" />
</CompositeCollection>
</ListBox.ItemsSource>
</ListBox>
I also tried to have 2 ListBox
but I've to have only one of those 2 collection selected, and I need that they are visually looking to be in the same group.
So what you think I could do?