How do you add a generic item to a ComboBox bound to a collection in WPF?

You could use a CompositeCollection as the ItemsSource for the ComboBox to include the "All" option. You need to set the Collection property of the CollectionContainer to your "ObservableCollection of Department objects.

You could use a CompositeCollection as the ItemsSource for the ComboBox to include the "All" option. You need to set the Collection property of the CollectionContainer to your "ObservableCollection of Department objects". All Not sure if this will be suitable for your filtering situation however...

1 Wow as an experienced WPF programmer I was not even aware of CompositeCollection! There are all sorts of workarounds for this when searching the internet, but none mention this! Incredible... – Aviad P.

Jan 28 '10 at 7:11 Yeah when I read this I was amazed. I have been doing some looking into it this morning and I think it will do the trick. Right now the filtering is done in the building of the Linq query so I am thinking I can test for 'All' and if that is not selected iterate the peopleCollection.In the future I was planning on refactoring and using a CollectionViewSource to filter the view without requerying; I'm not sure how that would work but for this question I have my answer.

Thank You! – Mike B Jan 28 '10 at 16:01 1 @Aviad yes it is a nice solution, one thing that does suck a bit is that you can't bind to the Collection property via DataContext as CompositeCollection is not Freezable. This can be worked around by binding to a static resource... – Simon Fox Jan 28 '10 at 19:59 1 the solution to this question has a an example of how to bind in this manner stackoverflow.

Com/questions/1189052/… not particularly pretty IMO but does the trick... – Simon Fox Jan 28 '10 at 20:07.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions