2

What I want to archive is a class similar to CompositCollection for WinRT.

<ListBox Name="list" Margin="30">

    <ListBox.ItemsSource>
        <test:CompositeCollectionView>
            <!--Using this the elements are where they belong-->
            <!--<test:CompositeCollectionView.Collection>-->


            <ListBoxItem Content="Value 1"/>

            <test:CollectionContainer >
                <ListBoxItem Content="Value 2"/>
                <ListBoxItem Content="Value 3"/>
                <ListBoxItem Content="Value 4"/>
            </test:CollectionContainer>

            <ListBoxItem Content="Value 5"/>

            <!--</test:CompositeCollectionView.Collection>-->
        </test:CompositeCollectionView>
    </ListBox.ItemsSource>
</ListBox>

For this I have the class CompositCollectionView. This class implements ObservableCollection and has an property Collection (which is itself an ObservableCollection). Every Object added to Collection will be added to CompositeCollectionView unless it is a CollectionContainer. If it is a CollectionContainer all items of this will be added.

Both CompositCollectionView and CollectionContainer have a property Collection of ObservableCollection. Both have the ContentProperty set. For CollectionContainer this works, for CompositCollectionView which implements ObservableCollection the items will be added directly to CompositCollectionView.

It seams the Collection has an higher priority than the Attribute. Is there a way to change this?

lokimidgard
  • 1,039
  • 10
  • 26

0 Answers0