I've been pulling my hair out on this forever. I'm developing an application that has items with custom fields. Sometimes the user will choose an option from the custom field, sometimes they'll leave it blank. I'm trying to get a RadComboBox to display the selected item only if the item is not null. If the item is null, then the combobox should display nothing (or a notice it's blank).
What's happening is either the combobox does not keep in sync, or it defaults to the first item in the collection. I need it to be in sync, but not default to the first item in the list if the property is null. For example simplified view of my ViewModel:
Class CustomField: Id as Integer, Description as String
ViewModel:
Public Property Selection as CustomField
Public Options as ObservableCollection(Of CustomField)
WPF:
<telerik:RadComboBox x:Name="rcbDropDown"
ItemsSource="{Binding Path=Options}"
SelectedValuePath="Id"
DisplayMemberPath="Choice"
SelectedItem="{Binding Path=Selection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ClearSelectionButtonContent="Clear"
ClearSelectionButtonVisibility="Visible"
IsEditable="False"
IsReadOnly="{Binding Path=IsReadOnly}"
EmptyText="Not Set"
UpdateSelectionOnLostFocus="True"
/>
I've tried multiple combinations of SelectedItem Mode=TwoWay, OneWayToSource and IsSyncronizedWithCurrentItem=True/False/NULL
I either end up with them syncing and the combo box defaulting to the first item on the list automatically, and pushing that into the viewmodel when the record is viewed, or not syncing. I can't get it to only show the selected item when it's not null. Any help would be appreciated!