title | page_title | description | type | slug | position | tags | ticketid | res_type |
---|---|---|---|---|---|---|---|---|
DataForm DataFormComboBoxField SelectedItem Becomes Null After Commit Button Click |
DataFormComboBoxField Selection Cleared When the Control Gets Unloaded from the Visual Tree |
The SelectedItem property of the DataFormComboBoxField is set to null after the changes are committed and RadDataForm control is unloaded. |
troubleshooting |
kb-dataform-comboboxfield-null-selection |
0 |
kb |
1549500 |
kb |
Product Version | |
Product | RadDataForm for WPF |
The following setup produces a null
value in the SelectedItem
of the RadDataFormComboBoxField on Commit button click.
{{region kb-dataform-comboboxfield-null-selection-0}} <telerik:DataFormComboBoxField DataMemberBinding="{Binding SelectedItem}" ItemsSource="{Binding Items}" /> {{endregion}}
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.
To resolve this, add a RadComboBox
control directly inside of the Content
of the data field.
{{region kb-dataform-comboboxfield-null-selection-1}}
telerik:DataFormComboBoxField
<telerik:RadComboBox SelectedItem="{Binding SelectedItem}"
ItemsSource="{Binding Items}" />
</telerik:DataFormComboBoxField>
{{endregion}}