Xamarin 表单:如何复制条目值?

Xamarin forms: How to copy an entry value?

我想从我的应用程序复制一个值并将其粘贴到同一应用程序的任何其他位置或应用程序外部。

我已经在 this thread 中寻找答案:

所以我使用了 Clipboard.SetText(txtClipboard.Text); 并添加了 using System.Windows.Forms;using System.Windows; 个命名空间。但是,我收到一个错误:

clipboard does not exist in the current context.

需要任何 nuget 包吗?

提前致谢

有个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.

设置文本

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

获取文本

string clipboardText = await CrossClipboard.Current.GetTextAsync();