gray laptop computer showing html codes in shallow focus photography

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>

    1 Comment

Leave A Reply

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

You May Also Like

In this post, you’ll learn about the error message “FileOpenAccessDenied – You do not have permissions to open this file...
  • .NET
  • December 3, 2024
You might have had a situation where your code once worked fine in ASP.NET application but now throws the below...
  • .NET
  • December 3, 2024
C# uses the flower bracket “{” and “}” to identify the block or scope of the function or program ....
  • .NET
  • December 3, 2024