It’s important that the users can copy relevant texts from their applications. That’s why I explain you a simpler way to do it. Let’s see!
We will follow these steps:
- Adding the Xamarin.Plugins.Clipboard
- Supported platforms
- Adding Copy/Paste actions in our applications
- Creating an example
First of all.. What do I need?
✔ Add from NuGet Package the plugin: Xamarin.Plugins.Clipboard:
Supports following platforms:
Xamarin.Android – Xamarin.iOS – Xamarin.Mac – Windows 10 UWP – Gtk# 2.12
How to add copy and paste action in our application?
To use it, we have to activate properties that allow us to copy and gets the selected text. Now, I´m going to explain you each of them:
- ✏ SetText: This property sets the text that you want to copy from your application. Accepts a string value.
- ? GetTextAsync: Gets the text copied. this property is a Task-based API and that’s the reason why we need to use the await, like I show you in the example. Returns a Task<string> value.
Creating an example
Good luck with your implementation! ?