Files
WPF_Practice/PacticeSolution/CommandPatternSample/MainWindow.xaml

36 lines
1.6 KiB
Plaintext
Raw Normal View History

2023-07-10 17:38:39 +09:00
<Window x:Class="CommandPatternSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CommandPatternSample"
xmlns:vm="clr-namespace:CommandPatternSample.ViewModel"
mc:Ignorable="d"
2023-07-10 17:50:09 +09:00
Title="MainWindow" Height="300" Width="400"
FocusManager.FocusedElement="{Binding ElementName=tbName}">
2023-07-10 17:38:39 +09:00
<Window.DataContext>
<vm:EmpViewModel/>
</Window.DataContext>
<StackPanel Margin="10">
<TextBlock Text="Enter the employee name."/>
<TextBox x:Name="tbName"
2023-07-10 17:50:09 +09:00
Text="{Binding SelectedEmp.Name}">
<TextBox.InputBindings>
<KeyBinding Key="Enter"
Command="{Binding AddEmpCommand}"
CommandParameter="{Binding ElementName=tbName,Path=Text}"/>
</TextBox.InputBindings>
</TextBox>
2023-07-10 17:38:39 +09:00
<Button Content="Add"
Command="{Binding AddEmpCommand}"
CommandParameter="{Binding ElementName=tbName, Path=Text}"/>
<ListBox x:Name="lbEmps"
ItemsSource="{Binding Emps}"
SelectedItem="{Binding SelectedEmp}"
DisplayMemberPath="Name"/>
<Label Height="40" Width="150" HorizontalAlignment="Center"
Content="{Binding ElementName=lbEmps, Path=SelectedItem}"/>
</StackPanel>
</Window>