White space is not preserving inside Label of TextType Html.

Abraham John 111 Reputation points

Let me write my code:

<Label Text="{Binding text}" TextType="Html"/>


text = "<pre>Hello      user<BR/>How     are you</pre>"

But the output is shown as:

Hello user
How are you

So how we can preserve all white spaces inside pre tag.

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,006 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,736 Reputation points


    Welcome to Microsoft Q&A!

    The Html style does not support <pre> based on my test .

    I even tried to use HtmlLabelPlugin , but still no luck , same result .

    If you want to display the html perfectly , I suggest you use WebView .

       var browser = new WebView();  
                   var htmlSource = new HtmlWebViewSource();  
                   htmlSource.Html = @"<html><body>  
         <pre>Hello      user<BR/>How     are you</pre>  
                   browser.Source = htmlSource;  
                   Content = browser;  


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments