Search code examples
c#windows-8charms-bar

Add a line break when sharing a text with the charm bar


For a Windows 8 App, in C#/Xaml, I am using the charm bar to share some content.

My problem is that I don't see my carriage returns in the text I want to share in the sharing application.

For example I want to share :

 Hello,

 Read this article about blablabla

 GoodBye

And on the email application in the charm bar it is displayed :

 Hello,Read this article about blablabla GoodBye

I tried to put some \n or %0d%0a or Environment.NewLine, but without any success...

How can I solve this problem ?

Thank you


Solution

  • If you're sending an email, you could use HTML.

    string message = "<p>Hello,</p><p>Read this article about blablabla</p>
                                                                 <p>GoodBye</p>";
    string htmlMessage = HtmlFormatHelper.CreateHtmlFormat(message);
    request.Data.SetHtmlFormat(htmlMessage);
    

    Of course, being HTML, you can use more advanced formatting and also include images. There's a full example of using the HTML format on MSDN.