<UserControl x:Class="Recipe4_7.MainPage"
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:local="clr-namespace:Recipe4_7"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:input="clr-
namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
Width="400"
Height="450">
<UserControl.Resources>
<local:BoolToVisibilityConverter x:Key="REF_BoolToVisibilityConverter" />
<DataTemplate x:Key="dtEmployee">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding FirstName}" />
<TextBlock Text="{Binding LastName}"
Grid.Column="1"
Grid.Row="0"
Margin="5,0,0,0" />
<TextBlock Text=" -> Error!!"
Foreground="Red"
Visibility=
"{Binding InError, Converter={StaticResource REF_BoolToVisibilityConverter}}"
Grid.Column="2" />
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot"
Background="White"
Margin="10,10,10,10">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0"
x:Name="lbx_Employees"
ItemTemplate="{StaticResource dtEmployee}"
SelectionChanged="lbx_Employees_SelectionChanged" />
<Grid x:Name="grid_NewButton"
Margin="0,2,0,0"
Grid.Row="1"
HorizontalAlignment="Right">
<Button x:Name="btn_New"
Click="btn_New_Click"
Content="New Employee" />
</Grid>
<input:ValidationSummary Grid.Row="2"
Margin="0,10,0,5" />
<Border Grid.Row="3"
Visibility="Collapsed"
x:Name="border_EmployeeForm"
Margin="0,2,0,0"
BorderBrush="Black"
BorderThickness="1"
Padding="1,1,1,1">
<Grid x:Name="grid_EmployeeForm">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.142*" />
<ColumnDefinition Width="0.379*" />
<ColumnDefinition Width="0.1*" />
<ColumnDefinition Width="0.097*" />
<ColumnDefinition Width="0.082*" />
<ColumnDefinition Width="0.2*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.10*" />
<RowDefinition Height="0.15*" />
<RowDefinition Height="0.15*" />
<RowDefinition Height="0.15*" />
<RowDefinition Height="0.45*" />
</Grid.RowDefinitions>
<TextBox HorizontalAlignment="Stretch"
Margin="1,1,1,1"
x:Name="tbxFName"
VerticalAlignment="Stretch"
Text=
"{Binding FirstName, Mode=TwoWay, UpdateSourceTrigger=Explicit}"
Grid.Row="1"
Width="Auto"
Grid.RowSpan="1"
Grid.ColumnSpan="2"
Grid.Column="1" />
<TextBox HorizontalAlignment="Stretch"
Margin="1,1,1,1"
x:Name="tbxLName"
VerticalAlignment="Stretch"
Text=
"{Binding LastName, Mode=TwoWay,UpdateSourceTrigger=Explicit}"
Grid.Row="1"
Grid.Column="3"
Width="Auto"
Grid.RowSpan="1"
Grid.ColumnSpan="3" />
<TextBlock HorizontalAlignment="Stretch"
Margin="1,1,1,1"
VerticalAlignment="Stretch"
Text="Last"
TextWrapping="Wrap"
Grid.RowSpan="1"
Grid.Column="4"
Grid.ColumnSpan="2"
Height="Auto"
Width="Auto" />
<TextBlock HorizontalAlignment="Center"
Margin="1,1,1,1"
VerticalAlignment="Center"
Text="First"
TextWrapping="Wrap"
Grid.RowSpan="1"
Grid.Column="1"
Width="Auto"
Height="Auto" />
<TextBlock HorizontalAlignment="Center"
Margin="1,1,1,1"
VerticalAlignment="Stretch"
Text="Name"
TextWrapping="Wrap"
Grid.RowSpan="1"
Grid.Row="1"
Height="Auto"
Width="Auto" />
<TextBlock HorizontalAlignment="Center"
Margin="1,1,1,1"
VerticalAlignment="Stretch"
Text="Street"
TextWrapping="Wrap"
Grid.Row="2"
Width="Auto" />
<TextBox HorizontalAlignment="Stretch"
x:Name="tbxStreet"
VerticalAlignment="Stretch"
Text=
"{Binding Address.Street, Mode=TwoWay, UpdateSourceTrigger=Explicit}"
Grid.Row="2"
Margin="1,1,1,1"
Grid.Column="1"
Grid.ColumnSpan="5"
Width="Auto" />
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Text="City"
TextWrapping="Wrap"
Margin="1,1,1,1"
Grid.Row="3" />
<TextBlock Text="State"
Margin="1,1,1,1"
TextWrapping="Wrap"
Grid.Column="2"
Grid.Row="3"
HorizontalAlignment="Center" />
<TextBlock Text="Zip"
Margin="1,1,1,1"
TextWrapping="Wrap"
Grid.Column="4"
Grid.Row="3"
HorizontalAlignment="Center" />
<TextBox HorizontalAlignment="Stretch"
x:Name="tbxCity"
Margin="1,1,1,1"
VerticalAlignment="Stretch"
Text=
"{Binding Address.City, Mode=TwoWay, UpdateSourceTrigger=Explicit}"
Grid.Row="3"
Grid.Column="1" />
<TextBox Background="Transparent"
Grid.Column="3"
Margin="1,1,1,1"
Grid.Row="3"
Text=
"{Binding Address.State, Mode=TwoWay,UpdateSourceTrigger=Explicit,
ValidatesOnExceptions=True,NotifyOnValidationError=True}"
x:Name="tbxState">
</TextBox>
<TextBox Background="Transparent"
Grid.Column="5"
Grid.Row="3"
Margin="1,1,1,1"
Text=
"{Binding Address.ZipCode, Mode=TwoWay, UpdateSourceTrigger=Explicit,
ValidatesOnExceptions=True,NotifyOnValidationError=True}"
x:Name="tbxZipCode" />
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Text="Phone"
Margin="1,1,1,1"
TextWrapping="Wrap"
Grid.Row="4" />
<TextBox Grid.Column="1"
Grid.Row="4"
Margin="1,1,1,1"
Text=
"{Binding PhoneNum, Mode=TwoWay, UpdateSourceTrigger=Explicit,
ValidatesOnExceptions=True,NotifyOnValidationError=True}"
x:Name="tbxPhoneNum" />
<StackPanel Orientation="Horizontal"
Grid.Column="4"
Margin="1,1,1,1"
Grid.ColumnSpan="2"
Grid.Row="4">
<Button Height="30.911"
Margin="2,2,2,0"
VerticalAlignment="Top"
Content="Save"
x:Name="btnSave"
Click="btnSave_Click" />
<Button Height="30.911"
Margin="2,2,2,0"
VerticalAlignment="Top"
Content="Close"
x:Name="btnClose"
Click="btnClose_Click" />
</StackPanel>
</Grid>
</Border>
</Grid>
</UserControl>
|