Cloud Training (Online)




XAML – Add Newline or line break in the Text attribute of TextBlock

In XAML , 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.

How to 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>