<Page x:Class="SchoolSample.StudentPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:di="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
Style="{StaticResource PageStyle}" Title="Student">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<cmd:EventToCommand Command="{Binding PageLoadedCommand}" />
</i:EventTrigger>
<i:EventTrigger EventName="Unloaded">
<cmd:EventToCommand Command="{Binding PageUnLoadedCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid x:Name="LayoutRoot">
<ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">
<StackPanel x:Name="ContentStackPanel" Style="{StaticResource ContentStackPanelStyle}">
<TextBlock Style="{StaticResource HeaderTextStyle}"
Text="{Binding Path=Strings.StudentPageTitle, Source={StaticResource ApplicationResources}}" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.RowSpan="4" Grid.ColumnSpan="2"
BorderThickness="1"
BorderBrush="Black"
CornerRadius="5">
<Border.Effect>
<DropShadowEffect ShadowDepth="3" />
</Border.Effect>
</Border>
<ListView x:Name="studentListView"
Grid.Column="0" Grid.Row="0"
MaxHeight="200"
Margin="10,20"
ScrollViewer.VerticalScrollBarVisibility="Auto"
SelectionMode="Single"
ItemContainerStyle="{DynamicResource ListViewItemContainerStyle}"
ItemsSource="{Binding Path=AllStudentsSource.View}"
IsEnabled="{Binding StudentListIsEnabled}">
<ListView.View>
<GridView>
<GridViewColumn
Header="Student ID"
DisplayMemberBinding="{Binding PersonId}" />
<GridViewColumn
Header="Name"
DisplayMemberBinding="{Binding Name}"/>
</GridView>
</ListView.View>
</ListView>
<Grid x:Name="studentGrid"
Grid.Column="1" Grid.Row="0"
MaxHeight="340"
Width="Auto" Margin="10,20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90" />
<ColumnDefinition MinWidth="150" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<di:DisplayLabel x:Name="nameLabel"
Grid.Row="0" Grid.Column="0"
Margin="0,0,10,10"
Target="{Binding ElementName=nameTextBox}" />
<DockPanel Grid.Row="0" Grid.Column="1"
Margin="0,0,10,10"
LastChildFill="True">
<di:DescriptionViewer x:Name="nameDescriptionViewer"
DockPanel.Dock="Right"
Target="{Binding ElementName=nameTextBox}" />
<TextBox x:Name="nameTextBox"
DockPanel.Dock="Left"
HorizontalAlignment="Stretch"
Margin="0,0,5,0"
Text="{Binding Path=CurrentStudent.Name, Mode=TwoWay,
NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
</DockPanel>
<di:DisplayLabel x:Name="enrollmentDateLabel"
Grid.Row="1" Grid.Column="0"
Margin="0,0,10,10"
Target="{Binding ElementName=enrollmentDateDatePicker}" />
<DockPanel Grid.Row="1" Grid.Column="1"
Margin="0,0,10,10"
LastChildFill="True">
<di:DescriptionViewer x:Name="enrollmentDateDescriptionViewer"
DockPanel.Dock="Right"
Target="{Binding ElementName=enrollmentDateDatePicker}" />
<DatePicker x:Name="enrollmentDateDatePicker"
DockPanel.Dock="Left"
Margin="0,0,5,0"
SelectedDate="{Binding Path=CurrentStudent.EnrollmentDate, Mode=TwoWay,
NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
</DockPanel>
</Grid>
<Grid
Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
Height="Auto" Width="Auto" Margin="12"
HorizontalAlignment="Stretch" VerticalAlignment="Top">
<Button
Width="75" Height="23" Margin="0,10,248,5"
VerticalAlignment="Top" HorizontalAlignment="Right"
Content="Add"
Command="{Binding Path=AddStudentCommand}"/>
<Button
Width="75" Height="23" Margin="0,10,167,5"
VerticalAlignment="Top" HorizontalAlignment="Right"
Content="Delete"
Command="{Binding Path=DeleteStudentCommand}"/>
<Button x:Name="editCommitStudentButton"
Width="75" Height="23" Margin="0,10,86,5"
VerticalAlignment="Top" HorizontalAlignment="Right"
Content="OK"
Command="{Binding Path=EditCommitStudentCommand}"/>
<Button
Width="75" Height="23" Margin="0,10,5,5"
VerticalAlignment="Top" HorizontalAlignment="Right"
Content="Cancel"
Command="{Binding Path=CancelEditStudentCommand}"/>
</Grid>
<di:ValidationSummary x:Name="studentValidationSummary"
Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
Margin="10,0,10,20"
Target="{Binding ElementName=studentGrid}"/>
<StackPanel
Grid.Row="3" Grid.Column="0"
Orientation="Vertical">
<TextBlock
VerticalAlignment="Center"
Margin="10,0"
FontWeight="Bold" FontSize="14"
Text="Courses Enrolled"/>
<ListView x:Name="coursesListView"
MaxHeight="200"
Margin="10,10,10,20"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemContainerStyle="{DynamicResource ListViewItemContainerStyle}"
ItemsSource="{Binding Path=CurrentStudent.Enrollments}">
<ListView.View>
<GridView>
<GridViewColumn
Header="Course ID"
DisplayMemberBinding="{Binding CourseId}" />
<GridViewColumn
Header="Course Title"
DisplayMemberBinding="{Binding Course.Title}" />
</GridView>
</ListView.View>
</ListView>
</StackPanel>
</Grid>
<Grid
Height="Auto" Width="Auto" Margin="12,12,12,0"
HorizontalAlignment="Stretch" VerticalAlignment="Top">
<Button
Width="75" Height="23" Margin="0,5,410,5"
VerticalAlignment="Top" HorizontalAlignment="Right"
Content="Refresh"
Command="{Binding Path=RefreshStudentCommand}"/>
<Button
Width="75" Height="23" Margin="0,5,329,5"
VerticalAlignment="Top" HorizontalAlignment="Right"
Content="Save"
Command="{Binding Path=SubmitStudentChangeCommand}"/>
<Button
Width="75" Height="23" Margin="0,5,248,5"
VerticalAlignment="Top" HorizontalAlignment="Right"
Content="Cancel"
Command="{Binding Path=CancelStudentChangeCommand}"/>
<Button
Width="75" Height="23" Margin="0,5,167,5"
VerticalAlignment="Top" HorizontalAlignment="Right"
Content="Refresh All"
Command="{Binding Path=RefreshAllCommand}"/>
<Button
Width="75" Height="23" Margin="0,5,86,5"
VerticalAlignment="Top" HorizontalAlignment="Right"
Content="Save All"
Command="{Binding Path=SubmitAllChangeCommand}"/>
<Button
Width="75" Height="23" Margin="0,5,5,5"
VerticalAlignment="Top" HorizontalAlignment="Right"
Content="Cancel All"
Command="{Binding Path=CancelAllChangeCommand}"/>
</Grid>
</StackPanel>
</ScrollViewer>
</Grid>
</Page>