Home.NETXAML – Add Newline or line break in the Text attribute of TextBlock

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

You May Also Like

In this post, you’ll learn about the error message “WorkbookNotSupported – The file you selected cannot be opened because it...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SpecifiedRangeNotFound – The requested range does not exist in the sheet.”...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SheetRangeMismatch – The sheet provided as the sheet argument is not...
  • .NET
  • December 17, 2022