0

I am trying to simulate Copy/Paste behavior of HTML text like Gmail does it. I.e. If I manually copy from Chrome page some text to the new mail in Gmail, the formatting of the text stays (more or less) with bullets, headers and etc.

I've tried use the Clipboard manager, but it contains only one Clip that has plain-text formatting. What do I do wrong?

    ClipboardManager clipboardManager = (ClipboardManager)Forms.Context.GetSystemService(Context.ClipboardService);

    ClipDescription decr = clipboardManager.PrimaryClip.Description;
    clipboardManager.PrimaryClip;
SushiHangover
  • 73,120
  • 10
  • 106
  • 165
Tanya
  • 109
  • 1
  • 13

1 Answers1

0

You need to use the GetItemAt method and choose if you wish to coerce it to the format that your app requires:

Example (assuming the first clip data is the one you want):

var htmlText = clipboardManager.PrimaryClip.GetItemAt(0).HtmlText;
var coercedHtmlText = clipboardManager.PrimaryClip.GetItemAt(0).CoerceToHtmlText;
var coercedFormattedStyledText = clipboardManager.PrimaryClip.GetItemAt(0).CoerceToStyledTextFormatted;
SushiHangover
  • 73,120
  • 10
  • 106
  • 165