I have a ComboBox that has an associated source of elements ... I have divided my example into key parts:
<UserControl x.Class="My.Application.ClientControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:conv="clr-namespace:My.Utilities.Converters" Name="ClientControl"> <UserControl.Resources> <ResourceDictionary> <CollectionViewSource Key="x:ClientsCollection" /> </ResourceDictionary> <conv:ClientOptions x:Key="ClientOptions" /> </UserControl.Resources> ... <ComboBox Name="Options" DataContext="ClientsCollection" ItemsSource="{Binding [ClientNumber], Converter={StaticResource ClientOptions}" /> </UserControl>
This works, but now I want to add one manual element to my combobox that will run alternative functions called "Other ...", so I need to move on to using CompositeCollection ... like this:
<ComboBox Name="Options" DataContext="ClientsCollection"> <ComboBox.ItemsSource> <CompositeCollection> <CollectionContainer Collection="{Binding [ClientNumber], Converter={StaticResource ClientOptions} /> <ComboBoxItem>Other...</ComboBoxItem> </CompositeCollection> </ComboBox>
Try as I could, related items just won't fill when using CompositeCollection. It shows only the manual ComboBoxItem "Other ...". If I delete this item, the list is empty. If I tie a breakpoint to the converter, it will not catch anything, which indicates that the binding did not even try.
I obviously donβt understand how the binding function in CompositeCollection happens. Can someone see the error in my XAML or explain what I am missing?
source share