Add Newline or line break in the Text attribute of TextBlock in Xaml

Your 2020 Plan. Learn 20 minutes a day for 20 days. Online courses from €9.99.

If you want to add the line break or newline within the string attribute of the TextBlock‘s Text property , you can use the hexidecimal encoded value 
 which represents the line feed.

Add Newline or line break in the Text attribute of TextBlock in Xaml

<TextBlock Text ="DeveloperPublish.com &#x0a; @isenthil">
</TextBlock>

The other option to achieve the same is to use the xml:space attribute of the textblock as shown below.

<TextBlock xml:space="preserve">
DeveloperPublish.com
@isenthil
</TextBlock>

We do have one more option to get the line break in Xaml . Use the <LineBreak> element

<TextBlock>
DeveloperPublish.com
<LineBreak/>
@isenthil
</TextBlock>

0 thoughts on “Add Newline or line break in the Text attribute of TextBlock in Xaml

  1. Pingback: XAMLNews #0001 | XAMLNews

Leave a Reply

Your email address will not be published. Required fields are marked *