I am trying to use a CompositeCollection to add a empty item in the comboBox. I am trying this code.
<ComboBox x:Name="cmbOrders" HorizontalAlignment="Left" Margin="5,16,0,0" VerticalAlignment="Top" Width="120" IsEditable="True" IsTextSearchEnabled="False" Text="{Binding OrdersText, UpdateSourceTrigger=PropertyChanged}" DisplayMemberPath="Order"><ComboBox.Resources><CollectionViewSource x:Key="comboBoxSource" Source="{Binding ElementName=cmbPersons, Path=SelectedItem.Orders}" /></ComboBox.Resources><ComboBox.ItemsSource><CompositeCollection><ComboBoxItem Content="Empty" ></ComboBoxItem><CollectionContainer Collection="{Binding Source={StaticResource comboBoxSource}}" /></CompositeCollection></ComboBox.ItemsSource></ComboBox>
I display the elements correctly, when I select an intem in the Persons comboBox, in the Orders combobox I display in the first position the empty element and later the orders of the person selected in the first comboBox.
The problem is that when I select the empty item the comboBox it is turn to red, like when I set an incorrect value in a control.
How could I avoid this behavior?
Thanks.
EDIT: I have notice that when I select this empty element the selectedItem is not fire, but the SelectedIndex do it. I guess that the origen of the problem is the same, but I would like to use selectedItem always.