New to Telerik UI for WPF? Download free 30-day trial

DataForm DataFormComboBoxField SelectedItem Becomes Null After Commit Button Click

Environment

Product Version
Product RadDataForm for WPF

Description

The following setup produces a null value in the SelectedItem of the RadDataFormComboBoxField on Commit button click.

<telerik:DataFormComboBoxField DataMemberBinding="{Binding SelectedItem}" 
                               ItemsSource="{Binding Items}" /> 
This happens if the Commit button unloads the control from the visual tree. For example, if hosted in dialog window that gets closed on commit.

Solution

To resolve this, add a RadComboBox control directly inside of the Content of the data field.

<telerik:DataFormComboBoxField> 
    <telerik:RadComboBox SelectedItem="{Binding SelectedItem}"  
                         ItemsSource="{Binding Items}"  /> 
</telerik:DataFormComboBoxField>   
In this article