I have created a RadComboBox and bound the data to a Collection of strings. I wanted to add a new item to the list when "New" item in the RadComboxBox is selected. i.e. RadComboBox will be set to editable when "New" item is selected and the entered text has to be add to the existing list only when Enter pressed or LostFocus. Could you help me to achieve this ?
XAML code to create the combobox with databinding
C# code to make the radcombobox editable and read the entered value,
C# code to add the entered text to Collection
It would be good if i can set the default text when the combo box is editable.
XAML code to create the combobox with databinding
<telerik:RadComboBox x:Name="SettingsNameList" ToolTip="Settings" Width="100" Height="25" ItemsSource="{Binding SettingsCV}" IsEditable="{Binding AddNewSetname,Mode=TwoWay}" Margin="120,5,550,0" Text="{Binding Path=NewSetName,Mode=TwoWay}" />C# code to make the radcombobox editable and read the entered value,
SettingsCV.CurrentChanged += new EventHandler(SettingsCV_SelectedItemChanged);private void SettingsCV_SelectedItemChanged(object sender, EventArgs e) { string item = SettingsCV.CurrentItem as string; if (item != null) { strDefaultSetName = item; if ("New" == strDefaultSetName) { bEditable = true; AddNewSetname = true; //strNewSetName = "Default"; //Raise property to update the UI NotifyPropertyChanged("AddNewSetname"); } } }C# code to add the entered text to Collection
public string NewSetName { get { return strNewSetName; } set { strNewSetName = value; strNewSetName.Trim(); m_strSettingsCollection.Add(strNewSetName); SettingsCV = new ListCollectionView(m_strSettingsCollection); NotifyPropertyChanged("SettingsCV"); } }It would be good if i can set the default text when the combo box is editable.