I have a combobox with which I'm adding in a <x:Null/>
at the beginning, as 'null' is a perfectly valid value for the bound property, but WPF doesn't seem willing to set it. Here's the XAML:
<ComboBox SelectedItem="{Binding PropertyName}">
<ComboBox.ItemsSource>
<CompositeCollection>
<x:Null/>
<CollectionContainer Collection="{Binding (available items)}"/>
</CompositeCollection>
</ComboBox.ItemsSource>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name, FallbackValue='(None)'}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
The collection in (available items)
has objects with a Name
property. The combobox correctly displays (None)
when the current value of PropertyName
is null, and it sets to an item in the collection when I selected one, but when I select (None)
, it doesn't set the property to null. Is there any way I can make it do this?