How can I add <Run Text=“xx”/> to TextBox c#? Or how can I append dynamic string to static string in TextBox?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 00:22:46

问题


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>

However, the same method doesn't work for TextBox, is there anyway to do the same thing with TextBox


回答1:


Try using RichEditBox.

<RichEditBox>
    <Paragraph>
       <Run Text="Static Text" />
       <Run Text="{Binding Dynamic}" />
    </Paragraph>
</RichEditBox>

If you're using Windows Phone Silverlight

<RichTextBox>
    <Paragraph>
       <Run Text="Static Text" />
       <Run Text="{Binding Dynamic}" />
    </Paragraph>
</RichTextBox>


来源:https://stackoverflow.com/questions/32977054/how-can-i-add-run-text-xx-to-textbox-c-or-how-can-i-append-dynamic-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!