This project has moved and is read-only. For the latest updates, please go here.
1
Vote

[PhoneTextBox] Cursor resets after BindingExpression.UpdateSource

description

I'm using the PhoneTextBox from the Windows Phone Toolkit with InputScope="Text" to get autocorrect and text suggestions. While typing in the keyboard the text suggestions appears above the keyboard and I choose one of them. Immediately after the suggestion is taken the cursor of the TextBox resets to the start position. So if I continue typing then the new text is inserted at the beginning of the TextBox.

This issue occurs when calling BindingExpression.UpdateSource in TextChanged event handler.
<toolkit:PhoneTextBox Hint="{Binding Path=LocalizedResources.EnterTitle, Source={StaticResource LocalizedStrings}}" Text="{Binding Name, Mode=TwoWay}" InputScope="Text"  TextChanged="OnTextChanged" />
        private void OnTextChanged(object sender, TextChangedEventArgs e)
        {
            var textBox = sender as TextBox;

            if (textBox == null) return;

            var bindingExpression = textBox.GetBindingExpression(TextBox.TextProperty);

            if (bindingExpression != null)
            {
                bindingExpression.UpdateSource();
            }
        }
Here's an example: After choosing the text suggestion "Tests" the cursor begin of line.

Image

comments