I am losing the selected value when going from one item to the other. My combox box is like this :
<local:ComboBoxEx x:Name="MYCB"
ItemsSource="{Binding Committente}"
SelectedValue="{Binding CommittenteSelected, Mode=TwoWay}"
SelectionChanged="committente_SelectionChanged"
/>
Committente comes from the ViewModel :
private ObservableCollection<CommittenteV> _Committente;
public ObservableCollection<CommittenteV> Committente
{
get { return _Committente; }
set
{
_Committente = value;
RaisePropertyChanged("Committente");
}
}
in the constructor of my viewmodel, I get my collection done like this :
Committente = ObservableCollectionConverter.GetObservableCollection<CommittenteV>(Service.getList);
Committente.Insert(0, null);
And I add a null Item in order to be able to have an item which symbolises “All Items”
My problem is that going from “real” items to this null item, I do not get CommittenteSelected equal to null but instead the value of the precedent item selected.
If this is not working, how could I decently implement this “all item” featur to feed the combobox of my filters ?
Thanks for your help,
You could also create a child object, of your CommittenteV object, so that when you are checking which object was selected you can use the ‘is’ operator.
This opens the door for you to be able to create a Processor class, that you can inject into your hosting VM. Throw the processor class into the SelectionChanged method and you can change the entire behavior of the class, by simply changing what Precessor you inject.
Using the interface you have a contract that states anytime this object is represented, to treat that object as if, all was selected.