mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Create a shared project with all Win App common files (8.1 and 10)
Finally use the dependency injected Resource Service
This commit is contained in:
27
WinAppCommon/Actions/SetupFocusAction.cs
Normal file
27
WinAppCommon/Actions/SetupFocusAction.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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 { return (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)));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user