Text cleared when the focus-out without selection.

2 posts, 1 answers
  1. Gongdo
    Gongdo avatar
    3 posts
    Member since:
    Apr 2013

    Posted 27 May 2013 Link to this post

    Hi guys,

    On your ComboBox Configurator example; http://demos.telerik.com/silverlight/#ComboBox/Configurator
    1. set the TextSearchMode to Contains.
    2. typed some text that is not contained in ItemsSource, say 'extra'. 
    3. pressed the 'Tab' key in order to escape the focus of the ComboBox.
    Then, the Text 'extra' that I've typed is cleared.

    It seems like kind of 'designed' behavior, however when you set the TextSearchMode to StartsWith and try instructions above, then you could see the Text 'extra' remained. Isn't it weird?

    I think the Text should be remained until the user clears the text explicitly.

    Can I get a work-around so that I can perform additional process with unexpected user-inputted-text?

    - gongdo
  2. Answer
    Vladi avatar
    749 posts

    Posted 30 May 2013 Link to this post


    By design the when an item is not selected in the control on LostFocus the input text is cleared in both TextSearchModes. The issue that could be reproduced in the online example seems to be caused by the example itself as we couldn't reproduce it in a sample project. If you want the non existing input text to be saved to the control you will need to implement it with the use of the KeyUp and LostFocus events.

    The next code snippet shows how to reset the input text to the ComboBox when the focus is lost:
    in the xaml:
    <telerik:RadComboBox LostFocus="RadComboBox_LostFocus_1"
    and in the code behind:
    private string inputText;
    private void RadComboBox_LostFocus_1(object sender, RoutedEventArgs e)
        var comboBox = sender as RadComboBox;
        comboBox.Text = inputText;
        inputText = null;
    private void RadComboBox_KeyUp_1(object sender, KeyEventArgs e)
        var comboBox = sender as RadComboBox;
        this.inputText = comboBox.Text;

    Hope this is helpful.


    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top