Files
modernkeepass/ModernKeePass10/Actions/SetupFocusAction.cs
Geoffroy BONNEVILLE 56d93a5187 Moved application code to the Application layer
Imported Win10 project
Code cleanup
WIP - Use common UWP services for Win8.1 and Win10
2020-04-06 20:20:45 +02:00

27 lines
903 B
C#

using System.Threading.Tasks;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Microsoft.Xaml.Interactivity;
namespace ModernKeePass.Actions
{
public class SetupFocusAction : DependencyObject, IAction
{
public Control TargetObject
{
get => (Control)GetValue(TargetObjectProperty);
set => SetValue(TargetObjectProperty, value);
}
public static readonly DependencyProperty TargetObjectProperty =
DependencyProperty.Register("TargetObject", typeof(Control), typeof(SetupFocusAction), new PropertyMetadata(null));
public object Execute(object sender, object parameter)
{
return Task.Factory.StartNew(
() => Dispatcher.RunAsync(CoreDispatcherPriority.Low,
() => TargetObject?.Focus(FocusState.Programmatic)));
}
}
}