File tree Expand file tree Collapse file tree 3 files changed +48
-2
lines changed
Expand file tree Collapse file tree 3 files changed +48
-2
lines changed Original file line number Diff line number Diff line change 2222 <SplitView .Resources>
2323
2424 <DataTemplate x : Key =" ApplicationTemplate" x : DataType =" viewModel:ApplicationViewModel" >
25- <TreeViewItem ItemsSource =" {x:Bind Path=Profiles, Mode=OneWay}" >
25+ <TreeViewItem ItemsSource =" {x:Bind Path=Profiles, Mode=OneWay}" PreviewKeyDown = " {x:Bind Path=HandleKeyboardInput} " >
2626 <selector : ApplicationSelectorView Application =" {x:Bind Mode=OneWay}" />
2727 </TreeViewItem >
2828 </DataTemplate >
2929
3030 <DataTemplate x : Key =" ProfileTemplate" x : DataType =" viewModel:ProfileViewModel" >
31- <TreeViewItem >
31+ <TreeViewItem PreviewKeyDown = " {x:Bind Path=HandleKeyboardInput} " >
3232 <selector : ProfileSelectorView Profile =" {x:Bind Mode=OneWay}" />
3333 </TreeViewItem >
3434 </DataTemplate >
Original file line number Diff line number Diff line change 1+ using Windows . System ;
2+ using Windows . UI . Core ;
3+
4+ namespace GHelper . View . Utility
5+ {
6+ public static class KeyboardState
7+ {
8+ public static CoreVirtualKeyStates ControlKeyState
9+ {
10+ get
11+ {
12+ CoreVirtualKeyStates controlKeyState = CoreWindow . GetForCurrentThread ( ) . GetKeyState ( VirtualKey . Control ) ;
13+
14+ if ( ( controlKeyState & CoreVirtualKeyStates . Down ) == CoreVirtualKeyStates . Down )
15+ {
16+ return CoreVirtualKeyStates . Down ;
17+ }
18+ else
19+ {
20+ return CoreVirtualKeyStates . None ;
21+ }
22+ }
23+ }
24+ }
25+ }
Original file line number Diff line number Diff line change 11using System . ComponentModel ;
22using System . Reflection ;
33using System . Runtime . CompilerServices ;
4+ using Windows . System ;
5+ using Windows . UI . Core ;
46using GHelper . Event ;
7+ using GHelper . View . Utility ;
58using GHelperLogic . Model ;
9+ using Microsoft . UI . Xaml . Input ;
610
711namespace GHelper . ViewModel
812{
@@ -64,6 +68,23 @@ public void FireDeletedEvent()
6468 {
6569 UserDeletedRecord ? . Invoke ( this ) ;
6670 }
71+
72+ public void HandleKeyboardInput ( object sender , KeyRoutedEventArgs keyboardEventInfo )
73+ {
74+ switch ( keyboardEventInfo . Key )
75+ {
76+ case VirtualKey . S :
77+ if ( KeyboardState . ControlKeyState == CoreVirtualKeyStates . Down )
78+ {
79+ FireSaveEvent ( ) ;
80+ }
81+ break ;
82+
83+ case VirtualKey . Delete or VirtualKey . Back :
84+ FireDeletedEvent ( ) ;
85+ break ;
86+ }
87+ }
6788
6889 protected abstract void OnPropertyChanged ( [ CallerMemberName ] string ? propertyName = null ) ;
6990 }
You can’t perform that action at this time.
0 commit comments