2

I want to copy a value from my app and paste it any other place of the same app or outside of the app.

I already looked for an answer in this thread:

So I used Clipboard.SetText(txtClipboard.Text); and added using System.Windows.Forms; and using System.Windows; namespaces. But, I am getting an error:

clipboard does not exist in the current context.

Any nuget package need for this?

Thanks in advance

Neuron
  • 5,141
  • 5
  • 38
  • 59
Sreejith Sree
  • 3,055
  • 4
  • 36
  • 105

1 Answers1

5

There is a clipboard plugin for Xamarin (supported platforms are iOS, Mac, Android, UWP and Gtk#). It supports saving text to and getting it from the clipboard in a cross-platform way. The NuGet package is available here.

To set text

CrossClipboard.Current.SetText("my clipboard text");

To get text

string clipboardText = await CrossClipboard.Current.GetTextAsync();
Paul Kertscher
  • 9,416
  • 5
  • 32
  • 57
  • I have some issues when copy and past text, started a new thread, can you please help. https://stackoverflow.com/questions/55369623/xamarin-forms-pasted-test-contains-symbol-instead-of-white-space – Sreejith Sree Mar 27 '19 at 04:08