key binding
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
xmlns:local="clr-namespace:CommandPatternSample"
|
||||
xmlns:vm="clr-namespace:CommandPatternSample.ViewModel"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="300" Width="400">
|
||||
Title="MainWindow" Height="300" Width="400"
|
||||
FocusManager.FocusedElement="{Binding ElementName=tbName}">
|
||||
<Window.DataContext>
|
||||
<vm:EmpViewModel/>
|
||||
</Window.DataContext>
|
||||
@@ -14,7 +15,13 @@
|
||||
<StackPanel Margin="10">
|
||||
<TextBlock Text="Enter the employee name."/>
|
||||
<TextBox x:Name="tbName"
|
||||
Text="{Binding SelectedEmp.Name}"/>
|
||||
Text="{Binding SelectedEmp.Name}">
|
||||
<TextBox.InputBindings>
|
||||
<KeyBinding Key="Enter"
|
||||
Command="{Binding AddEmpCommand}"
|
||||
CommandParameter="{Binding ElementName=tbName,Path=Text}"/>
|
||||
</TextBox.InputBindings>
|
||||
</TextBox>
|
||||
<Button Content="Add"
|
||||
Command="{Binding AddEmpCommand}"
|
||||
CommandParameter="{Binding ElementName=tbName, Path=Text}"/>
|
||||
|
Reference in New Issue
Block a user