You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
4.1 KiB

2 years ago
<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"
2 years ago
FontWeight="Bold"
2 years ago
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>
2 years ago
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListBox x:Name="lbStudentList" Grid.Row="0" IsSynchronizedWithCurrentItem="True" HorizontalContentAlignment="Stretch"
2 years ago
ItemTemplate="{StaticResource studentTemplate}"
2 years ago
ItemsSource="{Binding}">
<ListBox.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
2 years ago
<TextBlock Background="Black" Foreground="White" FontSize="18" FontWeight="Bold" HorizontalAlignment="Stretch">
<TextBlock Text="{Binding Name}" Margin="10 0 0 0"/> (<TextBlock Text="{Binding ItemCount}"/>Person)
2 years ago
</TextBlock>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListBox.GroupStyle>
</ListBox>
<StackPanel Grid.Row="1">
<Button x:Name="btnGroup"
Content="Gourpage"
Click="btnGroup_Click"/>
</StackPanel>
2 years ago
</Grid>
</Window>