Skip to content

Latest commit

 

History

History
50 lines (41 loc) · 1.47 KB

kb-dataform-comboboxfield-null-selection.md

File metadata and controls

50 lines (41 loc) · 1.47 KB
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

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.

[XAML]

{{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.

Solution

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

[XAML]

{{region kb-dataform-comboboxfield-null-selection-1}} telerik:DataFormComboBoxField <telerik:RadComboBox SelectedItem="{Binding SelectedItem}" ItemsSource="{Binding Items}" /> </telerik:DataFormComboBoxField>
{{endregion}}