I have some XAML code that makes me mad. It started all with adding a dummy Item for a not referenced value.
For this I had to implement a CollectionViewSource
and a CompositeCollection
.
Now I can't select the first Combobox Item, it appears but I cannot select it, because I set the DisplayMemberPath
in XAML (I guess so). Also the separator looks not as expected.
Let me show you:
If I don't set the XAML DisplayMemberPath
, I can use the Dummy Item but the bound ones are displayed incorrect:
XAML:
<ComboBox x:Name="G_cb_content_zuordnung"
Margin="165,0,0,0"
Grid.Row="1"
SelectedIndex="0"
VerticalAlignment="Top"
DisplayMemberPath="PartnerID"
HorizontalAlignment="Left"
Width="119">
<ComboBox.Resources>
<CollectionViewSource x:Key="ComboCollection" Source="{Binding Path=mySelectedItem.Stammkinder}" />
</ComboBox.Resources>
<ComboBox.ItemsSource>
<CompositeCollection>
<ComboBoxItem Content="Ohne Stammnummer" Name="NoPID" />
<Separator />
<CollectionContainer Collection="{Binding Source={StaticResource ComboCollection}, Mode=OneWay}" />
</CompositeCollection>
</ComboBox.ItemsSource>
</ComboBox>
All I need is a dummy / placeholder combobox item that gets shown on top of the ObservableCollection<myClass>
. Is my way of thinking wrong? Is there a smarter solution? Do I miss something in my solution?