在WinRt中共享文本时如何添加新行 [英] How to add new line while sharing text in WinRt

查看:123
本文介绍了在WinRt中共享文本时如何添加新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Windows 8上使用邮件客户端共享一些文本,在其中我要显示新行.使用\r\n时,它可以在记事本中正确显示它,但不能与DataTransferManager中的SetText功能一起使用.

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.

推荐答案

关键是在HTML中设置文本,而不是将其作为字符串发送.

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

假设您要共享的文本在string textToShare;中 请注意,您将以HTML格式发送字符串,因此您需要将所有换行符替换为<br/>

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/>

代替

theRequest.Data.SetText(textToShare);

使用

theRequest.Data.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(textToShare));

这篇关于在WinRt中共享文本时如何添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆