address book using mvvm
This commit is contained in:
54
PacticeSolution/AddressBook_MVVMSampleV2/View/MainView.xaml
Normal file
54
PacticeSolution/AddressBook_MVVMSampleV2/View/MainView.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<Window x:Name="winMain"
|
||||
x:Class="AddressBook_MVVMSampleV2.View.MainView"
|
||||
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:AddressBook_MVVMSampleV2.View"
|
||||
xmlns:vm="clr-namespace:AddressBook_MVVMSampleV2.ViewModel"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance vm:MainViewModel}"
|
||||
Title="Address Book" Height="350" Width="600"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DataGrid x:Name="grdPersons" Grid.Row="0"
|
||||
SelectionMode="Single" AutoGenerateColumns="False" IsReadOnly="True"
|
||||
AlternationCount="2" AlternatingRowBackground="LightSalmon"
|
||||
ItemsSource="{Binding Persons, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
|
||||
<DataGrid.InputBindings>
|
||||
<MouseBinding Gesture="LeftDoubleClick"
|
||||
Command="{Binding ModifyCommand}"
|
||||
CommandParameter="{Binding ElementName=grdPersons, Path=SelectedIndex}"/>
|
||||
</DataGrid.InputBindings>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Name" Width="100"
|
||||
Binding="{Binding Name}"/>
|
||||
<DataGridTextColumn Header="Gender"
|
||||
Binding="{Binding Gender}"/>
|
||||
<DataGridTextColumn Header="Phone number" Width="100"
|
||||
Binding="{Binding PhoneNumber}"/>
|
||||
<DataGridTextColumn Header="Address" Width="200"
|
||||
Binding="{Binding Address}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Content="Add" Width="100" Margin="3"
|
||||
Command="{Binding AddCommand}"/>
|
||||
<Button Content="Modify" Width="100" Margin="3"
|
||||
Command="{Binding ModifyCommand}"
|
||||
CommandParameter="{Binding ElementName=grdPersons, Path=SelectedIndex}"/>
|
||||
<Button Content="Delete" Width="100" Margin="3"
|
||||
Command="{Binding DeleteCommand}"
|
||||
CommandParameter="{Binding ElementName=grdPersons, Path=SelectedIndex}"/>
|
||||
<Button Content="Exit" Width="100" Margin="3"
|
||||
Command="{Binding ExitCommand}"
|
||||
CommandParameter="{Binding ElementName=winMain}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
Reference in New Issue
Block a user