I have a ComboBox in a WPF application that is bound to an ObservableCollection of Department objects in a C# ViewModel class. I want to use the combo box to filter another collection by department (And indeed it works for that now) The problem is that I want to add an additional option "All" to the top of the list. Is there a correct way to do this. Making a fake department feels wrong in so many ways.
The ComboBox
<ComboBox ItemsSource="{Binding Path=Departments}"
SelectedValue="{Binding Path=DepartmentToShow , Mode=TwoWay}" />
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".
Not sure if this will be suitable for your filtering situation however...
Suppose you have a ComboBox named
MyCombo
, an entity namedMyEntity
associated with a DomaineService namedMyDomainService
.Do not forget
and of course the using working well with your Web site of your entity and DomainService
You call a Proc named :
Then in the
CallBack
function: