如何添加 <Run Text="xx"/>到文本框 c#?或者如何将动态字符串附加到 TextBox 中的静态字符串? [英] How can I add <Run Text="xx"/> to TextBox c#? Or how can I append dynamic string to static string in TextBox?
本文介绍了如何添加 <Run Text="xx"/>到文本框 c#?或者如何将动态字符串附加到 TextBox 中的静态字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 WPF 中,我知道对于 TextBlock,当我想将一些动态"字符串附加到字符串时,我可以执行以下操作:
In WPF, I know that for TextBlock when I want to append some "dynamic" string to a string I can do something like the following :
<TextBlock>
<Run Text ="static string"/>
<Run Text="{Binding dynamicstring}"/>
</TextBlock>
然而,同样的方法对 TextBox 不起作用,反正有没有对 TextBox 做同样的事情
However, the same method doesn't work for TextBox, is there anyway to do the same thing with TextBox
推荐答案
尝试使用 RichEditBox.
Try using RichEditBox.
<RichEditBox>
<Paragraph>
<Run Text="Static Text" />
<Run Text="{Binding Dynamic}" />
</Paragraph>
</RichEditBox>
如果您使用的是 Windows Phone Silverlight
If you're using Windows Phone Silverlight
<RichTextBox>
<Paragraph>
<Run Text="Static Text" />
<Run Text="{Binding Dynamic}" />
</Paragraph>
</RichTextBox>
这篇关于如何添加 <Run Text="xx"/>到文本框 c#?或者如何将动态字符串附加到 TextBox 中的静态字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文