Files
modernkeepass/WinAppCommon/Actions/ClipboardAction.cs
Geoffroy BONNEVILLE 73670e8689 Create a shared project with all Win App common files (8.1 and 10)
Finally use the dependency injected Resource Service
2020-04-17 16:56:07 +02:00

28 lines
916 B
C#

using Windows.ApplicationModel.DataTransfer;
using Windows.UI.Xaml;
using Microsoft.Xaml.Interactivity;
namespace ModernKeePass.Actions
{
public class ClipboardAction : DependencyObject, IAction
{
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(ClipboardAction), new PropertyMetadata(string.Empty));
public object Execute(object sender, object parameter)
{
if (string.IsNullOrEmpty(Text)) return null;
var dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
dataPackage.SetText(Text);
Clipboard.SetContent(dataPackage);
return null;
}
}
}