0
votes

There is a command appendText in Windows Form Application to add text in a text box without removing previous texts.

But I didn't find any command in UWP(XAML) applications like appendText. What should I use in UWP(XAML) to do the same like appendText?

3

3 Answers

2
votes

I am afraid it's not possible. But if you wish increase speed you can bind TextBox value with compiled binding x:Bind
In this case if you change value in c# code-behind it will be changed very fast in UI

Text rendering is optimized in Windows 10. It's already 50% faster then in Windows 8.1 If you want to optimize TextBlock loading speed then you can:

  1. Set IsTextSelectionEnabled property to false and CharacterSpacing to 0 if you want have good TextBlock performance. LineHeight should be also set 0.
  2. Use default typography
  3. TextTrimming: Only the None, CharacterEllipsis, and WordEllipsis values
  4. Set up text with Text="" property

    <StackPanel>
    <TextBlock Text="This text is on the fast path."/>
    <TextBlock>This text is NOT on the fast path.</TextBlock>
    <StackPanel/>
    

You can read this and another recommendations here: Text block Performance considerations

0
votes

I found a simple way to do this:

{
    //prevString = the string availabe in textbox before adding newString
    //newString = the string I want to add as appendText

    //Get all string in textbox in prevText string
    string prevString = reciveTextBox.Text;
    //always print the prevString before printing newString
    reciveTextBox.Text = prevString + newString;
}

It works exactly as appendText!

0
votes

Here is a simple way:

textBox1.Text += "new text";

Same as appendText