Advertisement
Intermediate .NET MAUI, Device Features & Essentials

How do you use the Clipboard and Share APIs?

Short answer

Clipboard.Default.SetTextAsync/GetTextAsync copies and reads text. Share.Default.RequestAsync opens the OS share sheet with text or files (ShareTextRequest/ShareFileRequest), letting users send content to other apps.

Save .NET MAUI mock interview
Advertisement
AModel answer
Clipboard.Default.SetTextAsync/GetTextAsync copies and reads text. Share.Default.RequestAsync opens the OS share sheet with text or files (ShareTextRequest/ShareFileRequest), letting users send content to other apps.
await Clipboard.Default.SetTextAsync(couponCode);
await Share.Default.RequestAsync(new ShareTextRequest
{ Text = "Check this out!", Title = "Share" });
Real-world example
A coupon screen copies the code to the clipboard and offers a Share button to send a referral link to friends.
Likely follow-ups
  • How do you share a file? | Is Clipboard access async?
Related topics