Text value wiping out, and what is .TextInputString?

7 posts, 0 answers
  1. Kjell
    Kjell avatar
    275 posts
    Member since:
    Jun 2010

    Posted 27 Dec 2012 Link to this post

    I have a combobox which has a bound .Text field.  When my control first loads, the correct text appears in the box and the box receives focus.  When the box loses focus, the value is cleared out.  In the LostFocus event handler I can tell that both the .Text property and my corresponding business property have been set to NULL but I can't figure out why.  During my troubleshooting I noticed that the "TextInputString" property of the combobox still holds the correct value after .Text is somehow null.  Does this mean anything?

    I added a GotFocus event, and the weird thing is in that handler the value is still set. 

    So both .text and the underlying business object property are set properly in GotFocus, but then when I click off the box, in the LostFocus event, they are null. 

    One more detail, if I trigger LostFocus by clicking out of the window, then the property does not get lost, I guess because the focus is really still on the box.  But then if I click on another control it get's lost.

    I have probably 50 radComboBoxes all over my application without the issue, so I think it will be hard to duplicate in a standalone project.  Below is the xaml definition of my combobox.

    <controls:CustomMenuCombo x:Name="radCustom1Combo_Flick"  CanKeyboardNavigationSelectItems="True" Grid.Row="5" Grid.Column="1"
                                         Text="{Binding Custom1,Mode=TwoWay, FallbackValue=''}" IsEditable="True" VerticalAlignment="Top" SelectAllTextEvent="None"
                                          SelectionChanged="radCustom1Combo_SelectionChanged" CanAutocompleteSelectItems="True" IsFilteringEnabled="True"
                                                   GotFocus="radCustom1Combo_Flick_GotFocus"                                                 
                                         Visibility="Collapsed" LostFocus="radCustom1Combo_LostFocus" OpenDropDownOnFocus="False" Height="24"/>
  2. Kjell
    Kjell avatar
    275 posts
    Member since:
    Jun 2010

    Posted 27 Dec 2012 Link to this post

    Troubleshooting focus stuff can be annoying in debug mode because the act of the debugger popping up will fire lostfocus. 

    So to take that out of the equation, I'm checking the value of the box by writing it to a plain textbox in the Got/Lost focus events.  Here is what I'm finding:


    1) Everything loads, box appears to have the correct value.
    2) Click in the textbox, GotFocus event writes that value to another textbox and everything is still find.  This event handler does nothing else.
    3) Click out of the textbox, LostFocus event fails to write the value to the textbox because it is now null.

    QUESTION: HOW DID THIS VALUE BECOME NULL?
  3. DevCraft banner
  4. Kjell
    Kjell avatar
    275 posts
    Member since:
    Jun 2010

    Posted 27 Dec 2012 Link to this post

    More info...

    I tried binding another control to the same field, and as expected it gets wiped out when I click in the combobox and click out of it. 

    NOTE: This only occurs the first time, if I then select a value from the combobox dropdown and set it that way, I no longer have the issue until the next time it loads.
  5. Kjell
    Kjell avatar
    275 posts
    Member since:
    Jun 2010

    Posted 27 Dec 2012 Link to this post

    More info..


    1) I recently updated to the latest build, until now I have been using the 2011 Q3 libraries.  I've confirmed that this issue does not exist when using the old libraries.

    2) I was wrong about it only appearing with this specific box, the issue exists with other similarly configured comboboxes in the same control.

    3) You may have noticed I am using a custom control (which inherits radcombobox).  I just tried changing the XAML to use radcombobox and the issue still exists.
  6. Kjell
    Kjell avatar
    275 posts
    Member since:
    Jun 2010

    Posted 28 Dec 2012 Link to this post

    I've updated to the latest internal libraries and this did not fix my issue, but I have more info. 

    I noticed if I type in any text which doesn't corrospond to a valid entry in the dropdown then when I leave the field it will wipe the text.  This is happening in other areas of my app as well.  Luckily I have a combobox which doesn't do it, so I'm trying to figure out what's different about that one.

  7. Kjell
    Kjell avatar
    275 posts
    Member since:
    Jun 2010

    Posted 28 Dec 2012 Link to this post

    Ok I've narrowed the issue down to IsFilteringEnabled=true, and I can duplicate it in the demo.  Is this behavior by design? 
  8. George
    Admin
    George avatar
    1332 posts

    Posted 03 Jan 2013 Link to this post

    Hello Kjell,

    Your remarks are correct and we can confirm that this behavior is by design. We will consider making some changes to RadComboBox in order to make it more intuitive in cases, including the given scenario.

    Please, note that the TextInputString property holds value of the typed text only, but the Text property can be the typed text or the autocompleted text, which is different. 

    Regards,
    George
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner