[英]Append text in UWP(XAML)?
There is a command appendText in Windows Form Application to add text in a text box without removing previous texts. Windows窗体应用程序中有一个命令appendText,可在不删除先前文本的情况下在文本框中添加文本。
But I didn't find any command in UWP (XAML) applications like appendText . 但是我在诸如appendText的 UWP (XAML)应用程序中找不到任何命令。 What should I use in UWP (XAML) to do the same like appendText ? 我应该在UWP (XAML)中使用什么来做类似于appendText的操作 ?
I am afraid it's not possible. 恐怕不可能。 But if you wish increase speed you can bind TextBox value with compiled binding x:Bind 但是,如果您希望提高速度,可以将TextBox值与已编译的绑定x:Bind绑定
In this case if you change value in c# code-behind it will be changed very fast in UI 在这种情况下,如果您在c#代码后面更改值,则它将在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: 在Windows 10中优化了文本呈现,它已经比Windows 8.1快了50%。如果要优化TextBlock的加载速度,则可以:
Set up text with Text="" property 使用Text =“”属性设置文本
<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 您可以在此处阅读此建议和其他建议: 文本块性能注意事项
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 ! 它的工作原理与appendText完全一样!
Here is a simple way: 这是一个简单的方法:
textBox1.Text += "new text";
Same as appendText 与appendText相同
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.