How to add new line while sharing text in WinRt

2019-06-25 10:02发布

I want to share some text using mail client on windows 8, in which I want to display new lines. It displays it correctly in notepad on using \r\n but doesn't work with the SetText function in DataTransferManager.

1条回答
成全新的幸福
2楼-- · 2019-06-25 10:26

The key is to set text in HTML and not send it as string.

Suppose the text you want to share is in string textToShare; Note that you will be sending a string in HTML, so you need to replace all new line characters with <br/>

instead of

theRequest.Data.SetText(textToShare);

use

theRequest.Data.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(textToShare));
查看更多
登录 后发表回答