Added Enter( return key ) handler to AmountWindow

This commit is contained in:
Konrad Pierzyński 2019-01-22 21:40:46 +01:00
parent 3fbea7ec0d
commit d1f4178bc1
2 changed files with 33 additions and 23 deletions

View File

@ -15,7 +15,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Magazyn.Windows" xmlns:local="clr-namespace:Magazyn.Windows"
mc:Ignorable="d" mc:Ignorable="d"
Title="Magazyn" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize"> Title="Magazyn" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown">
<Grid> <Grid>
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,82,0,0" TextWrapping="Wrap" Text="fruitName" Width="64" Height="16" VerticalAlignment="Top"/> <TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,82,0,0" TextWrapping="Wrap" Text="fruitName" Width="64" Height="16" VerticalAlignment="Top"/>

View File

@ -57,7 +57,7 @@ namespace Magazyn.Windows
} }
private void saveButton_Click(object sender, RoutedEventArgs e) private void SendNewQuantity()
{ {
int amount = int.Parse(amountToChange.Text); int amount = int.Parse(amountToChange.Text);
try try
@ -81,9 +81,19 @@ namespace Magazyn.Windows
this.Close(); this.Close();
} }
private void saveButton_Click(object sender, RoutedEventArgs e)
{
SendNewQuantity();
}
private void cancelButton_Click(object sender, RoutedEventArgs e) private void cancelButton_Click(object sender, RoutedEventArgs e)
{ {
this.Close(); this.Close();
} }
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return) SendNewQuantity();
}
} }
} }