Xamarin forms: How to copy an entry value?

半城伤御伤魂 提交于 2019-12-24 08:49:14

问题


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


回答1:


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();


来源:https://stackoverflow.com/questions/50342391/xamarin-forms-how-to-copy-an-entry-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!