|
|
|
|
<Window x:Class="ListSample.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:model="clr-namespace:ListSample.Model"
|
|
|
|
|
xmlns:local="clr-namespace:ListSample"
|
|
|
|
|
xmlns:modelView="clr-namespace:ListSample.ViewModel"
|
|
|
|
|
mc:Ignorable="d"
|
|
|
|
|
Title="MainWindow" Height="450" Width="400">
|
|
|
|
|
|
|
|
|
|
<Window.DataContext>
|
|
|
|
|
<modelView:StudentList x:Name="_studentList"/>
|
|
|
|
|
</Window.DataContext>
|
|
|
|
|
|
|
|
|
|
<Window.Resources>
|
|
|
|
|
<DataTemplate x:Key="studentTemplate">
|
|
|
|
|
<Grid>
|
|
|
|
|
<Grid.ColumnDefinitions>
|
|
|
|
|
<ColumnDefinition Width="Auto"/>
|
|
|
|
|
<ColumnDefinition Width="Auto"/>
|
|
|
|
|
<ColumnDefinition Width="*"/>
|
|
|
|
|
<ColumnDefinition Width="Auto"/>
|
|
|
|
|
</Grid.ColumnDefinitions>
|
|
|
|
|
<Grid.RowDefinitions>
|
|
|
|
|
<RowDefinition Height="Auto"/>
|
|
|
|
|
<RowDefinition Height="Auto"/>
|
|
|
|
|
<RowDefinition Height="Auto"/>
|
|
|
|
|
</Grid.RowDefinitions>
|
|
|
|
|
|
|
|
|
|
<Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Width="64" Height="64" Margin="0 0 20 0"
|
|
|
|
|
Source="./Resources/Man.png"/>
|
|
|
|
|
<TextBlock Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"
|
|
|
|
|
Text="Name: "/>
|
|
|
|
|
<TextBlock Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"
|
|
|
|
|
FontSize="18" FontWeight="Bold"
|
|
|
|
|
Text="{Binding Name}"/>
|
|
|
|
|
<Button x:Name="btnDelete" Grid.Column="3" Grid.Row="1" Margin="3"
|
|
|
|
|
Content="Delete"
|
|
|
|
|
Tag="{Binding Name}"
|
|
|
|
|
Click="btnDelete_Click"/>
|
|
|
|
|
<TextBlock Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"
|
|
|
|
|
Text="Age: "/>
|
|
|
|
|
<TextBlock Grid.Column="2" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"
|
|
|
|
|
Text="{Binding Age}"/>
|
|
|
|
|
<TextBlock Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center"
|
|
|
|
|
Text="Phone: "/>
|
|
|
|
|
<TextBlock Grid.Column="2" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center"
|
|
|
|
|
Text="{Binding Phone}"/>
|
|
|
|
|
<Border Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
|
|
|
|
|
BorderBrush="Black" BorderThickness="0 0 0 1"/>
|
|
|
|
|
</Grid>
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</Window.Resources>
|
|
|
|
|
|
|
|
|
|
<Grid>
|
|
|
|
|
<ListBox x:Name="lbStudentList" IsSynchronizedWithCurrentItem="True" HorizontalContentAlignment="Stretch"
|
|
|
|
|
ItemTemplate="{StaticResource studentTemplate}"
|
|
|
|
|
ItemsSource="{Binding}"/>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Window>
|