How can I add to TextBox c#? Or h

2019-07-08 09:45发布

问题:

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>