Skip to content

Commit 4df4b56

Browse files
committed
Deleting and saving when view has focus
1 parent 7a4176a commit 4df4b56

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

GHelper/GHelper/View/ApplicationDataView.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
77
mc:Ignorable="d"
8+
9+
KeyUp="{x:Bind Path=Application.HandleKeyboardInput}"
810

911
Style="{StaticResource RecordViewStyle}">
1012

11-
<TextBox x:Name="NameTextBox" Header="Name" Text="{x:Bind Application.DisplayName, Mode=OneWay, FallbackValue=''}" Style="{StaticResource StandardTextBox}" KeyUp="HandleNamedChanged"/>
13+
<TextBox x:Name="NameTextBox" Header="Name" Text="{x:Bind Application.DisplayName, Mode=OneWay, FallbackValue=''}" Style="{StaticResource StandardTextBox}" PreviewKeyUp="HandleNameEdit"/>
1214
<TextBox Header="Type" Text="{x:Bind Application.ApplicationType, Mode=OneWay, FallbackValue=''}" Style="{StaticResource ImmutableTextBox}"/>
1315
<TextBox Header="Application ID" Text="{x:Bind Application.Application.ApplicationID, Mode=OneWay, FallbackValue=''}" Style="{StaticResource ImmutableMonoSpacedTextBox}"/>
1416
<TextBox Header="Path" Text="{x:Bind Application.Application.ApplicationPath, Mode=OneWay, FallbackValue=''}" Style="{StaticResource ImmutableMonoSpacedTextBox}"/>

GHelper/GHelper/View/ApplicationDataView.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ public ApplicationDataView()
3131
this.InitializeComponent();
3232
}
3333

34-
private void HandleNamedChanged(object sender, KeyRoutedEventArgs input)
34+
private void HandleNameEdit(object sender, KeyRoutedEventArgs input)
3535
{
3636
NamedChanged?.Invoke(sender, input);
37+
input.Handled = true;
3738
}
3839

3940
private void DetermineNameViewStyle()

GHelper/GHelper/View/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
<SplitView.Resources>
2323

2424
<DataTemplate x:Key="ApplicationTemplate" x:DataType="viewModel:ApplicationViewModel">
25-
<TreeViewItem ItemsSource="{x:Bind Path=Profiles, Mode=OneWay}" PreviewKeyDown="{x:Bind Path=HandleKeyboardInput}">
25+
<TreeViewItem ItemsSource="{x:Bind Path=Profiles, Mode=OneWay}" KeyUp="{x:Bind Path=HandleKeyboardInput, Mode=OneWay}">
2626
<selector:ApplicationSelectorView Application="{x:Bind Mode=OneWay}"/>
2727
</TreeViewItem>
2828
</DataTemplate>
2929

3030
<DataTemplate x:Key="ProfileTemplate" x:DataType="viewModel:ProfileViewModel">
31-
<TreeViewItem PreviewKeyDown="{x:Bind Path=HandleKeyboardInput}">
31+
<TreeViewItem KeyUp="{x:Bind Path=HandleKeyboardInput, Mode=OneWay}">
3232
<selector:ProfileSelectorView Profile="{x:Bind Mode=OneWay}" />
3333
</TreeViewItem>
3434
</DataTemplate>

GHelper/GHelper/View/ProfileView.xaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:view="using:GHelper.View"
5-
x:Class="GHelper.View.ProfileView">
5+
x:Class="GHelper.View.ProfileView"
6+
7+
KeyUp="{x:Bind Path=Profile.HandleKeyboardInput}">
68

79
<Grid>
810
<Grid.RowDefinitions>
@@ -13,9 +15,9 @@
1315
<view:RecordViewControls x:Name="RecordViewControls" Grid.Row="0" Grid.Column="0" Style="{StaticResource RecordViewControlsStyle}"/>
1416

1517
<StackPanel Grid.Row="1" Grid.Column="0" Style="{StaticResource RecordViewStyle}">
16-
<TextBox x:Name="NameDisplay" Header="Name" Text="{x:Bind Profile.DisplayName, Mode=OneWay, FallbackValue=''}" Style="{StaticResource ResourceKey=StandardTextBox}" KeyUp="HandleNameChange" GettingFocus="ShowEditableName" LosingFocus="ShowDisplayName"/>
17-
<ToggleSwitch Header="Currently Active" OffContent="Inactive" OnContent="Active" IsOn="{x:Bind Profile.ActiveForApplication, Mode=TwoWay}" Style="{StaticResource StandardToggleSwitch}"/>
18-
<TextBox Header="Profile ID" Text="{x:Bind Profile.Profile.ID, Mode=OneWay, FallbackValue=''}" Style="{StaticResource ResourceKey=ImmutableMonoSpacedTextBox}"/>
18+
<TextBox x:Name="NameDisplay" Header="Name" Text="{x:Bind Profile.DisplayName, Mode=OneWay, FallbackValue=''}" Style="{StaticResource ResourceKey=StandardTextBox}" PreviewKeyUp="HandleNameEdit" GettingFocus="ShowEditableName" LosingFocus="ShowDisplayName"/>
19+
<ToggleSwitch Header="Currently Active" OffContent="Inactive" OnContent="Active" IsOn="{x:Bind Profile.ActiveForApplication, Mode=TwoWay}" Style="{StaticResource StandardToggleSwitch}"/>
20+
<TextBox Header="Profile ID" Text="{x:Bind Profile.Profile.ID, Mode=OneWay, FallbackValue=''}" Style="{StaticResource ResourceKey=ImmutableMonoSpacedTextBox}"/>
1921
</StackPanel>
2022
</Grid>
2123

GHelper/GHelper/View/ProfileView.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ void RecordView.SendRecordChangedNotification()
4747
OnPropertyChanged(nameof(GHubRecordViewModel));
4848
}
4949

50-
private void HandleNameChange(object sender, RoutedEventArgs routedEventInfo)
50+
private void HandleNameEdit(object sender, KeyRoutedEventArgs routedEventInfo)
5151
{
5252
RecordView.ChangeName(this, sender);
53+
routedEventInfo.Handled = true;
5354
}
5455

5556
private void ResetAppearance()

0 commit comments

Comments
 (0)