How to use the Clipboard on Windows Phone 8.1 apps

How to use the Clipboard on Windows Phone 8.1 apps

Clipboard api are only available for Windows 8.1 and Windows 10, but not for Windows Phone 8.1 apps

Yes and no

Yes, Windows Phone 8.1 apps have no access to this cool feature, but only on Windows Phone 8.1 devices! If your app runs on Windows 10 mobile, you can use reflection to use it! Here is the code to use:

var clipboardType= typeof(DataPackage).GetTypeInfo().Assembly.GetType("Windows.ApplicationModel.DataTransfer.Clipboard");
if (clipboardType != null)
{
    var dataPackage = new DataPackage();
    dataPackage.SetText("Hello You!");
    clipboardType.GetRuntimeMethod("SetContent",new[] {typeof(DataPackage) }).Invoke(null,new object[] { dataPackage });
}

If you have not enough time to update your app to UWP, do not hesitate to use reflections to improve your 8.1 app with some 10 exclusive features!

Comments are closed.