This is a migrated thread and some comments may be shown as answers.

Text value wiping out, and what is .TextInputString?

6 Answers 50 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Kjell asked on 27 Dec 2012, 07:18 PM

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"/>

6 Answers, 1 is accepted

Sort by
0
Kjell
Top achievements
Rank 1
answered on 27 Dec 2012, 07:33 PM
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?
0
Kjell
Top achievements
Rank 1
answered on 27 Dec 2012, 07:38 PM
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.
0
Kjell
Top achievements
Rank 1
answered on 27 Dec 2012, 08:11 PM
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.
0
Kjell
Top achievements
Rank 1
answered on 28 Dec 2012, 07:17 PM
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.

0
Kjell
Top achievements
Rank 1
answered on 28 Dec 2012, 07:52 PM
Ok I've narrowed the issue down to IsFilteringEnabled=true, and I can duplicate it in the demo.  Is this behavior by design? 
0
George
Telerik team
answered on 03 Jan 2013, 12:44 PM
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.

Tags
ComboBox
Asked by
Kjell
Top achievements
Rank 1
Answers by
Kjell
Top achievements
Rank 1
George
Telerik team
Share this question
or