view SilverlightValidation/SilverlightValidation/UserView.xaml @ 51:02b1513f679a

finished silverlight validation
author Steven Hollidge <stevenhollidge@hotmail.com>
date Thu, 19 Apr 2012 05:59:28 +0100
parents 64f19743cfd6
children f5c13b2b0149
line wrap: on
line source

<UserControl x:Class="SilverlightValidation.UserView"
             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:p="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls"
             xmlns:s="clr-namespace:System;assembly=mscorlib"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             d:DesignHeight="350"
             d:DesignWidth="450"
             mc:Ignorable="d">

    <Grid x:Name="LayoutRoot" Background="White">

        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="50" />
            <RowDefinition Height="150" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="300" />
            <ColumnDefinition Width="30" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="1"
                   Grid.Column="1"
                   Style="{StaticResource LabelStyle}"
                   Text="Username:" />

        <TextBox x:Name="tbUsername"
                 Grid.Row="1"
                 Grid.Column="2"
                 LostFocus="tbUsername_LostFocus"
                 Style="{StaticResource TextBoxStyle}"
                 Text="{Binding Username,
                                Mode=TwoWay,
                                ValidatesOnDataErrors=True,
                                NotifyOnValidationError=True}" />

        <sdk:DescriptionViewer Grid.Row="1"
                               Grid.Column="3"
                               Width="20"
                               Description="Required"
                               Target="{Binding ElementName=tbUsername}" />

        <TextBlock Grid.Row="2"
                   Grid.Column="1"
                   Style="{StaticResource LabelStyle}"
                   Text="Password:" />

        <PasswordBox x:Name="tbPassword"
                     Grid.Row="2"
                     Grid.Column="2"
                     LostFocus="tbPassword_LostFocus"
                     Password="{Binding Password,
                                        Mode=TwoWay,
                                        ValidatesOnDataErrors=True,
                                        NotifyOnValidationError=True}" />

        <sdk:DescriptionViewer Grid.Row="2"
                               Grid.Column="3"
                               Width="20"
                               Description="Required"
                               Target="{Binding ElementName=tbPassword}" />

        <TextBlock Grid.Row="3"
                   Grid.Column="1"
                   Style="{StaticResource LabelStyle}"
                   Text="Email:" />

        <TextBox x:Name="tbEmail"
                 Grid.Row="3"
                 Grid.Column="2"
                 LostFocus="tbEmail_LostFocus"
                 Style="{StaticResource TextBoxStyle}"
                 Text="{Binding Email,
                                Mode=TwoWay,
                                ValidatesOnDataErrors=True,
                                NotifyOnValidationError=True}" />

        <sdk:DescriptionViewer Grid.Row="3"
                               Grid.Column="3"
                               Width="20"
                               Description="Required"
                               Target="{Binding ElementName=tbEmail}" />

        <TextBlock Grid.Row="4"
                   Grid.Column="1"
                   Style="{StaticResource LabelStyle}"
                   Text="Date of Birth:" />

        <sdk:DatePicker x:Name="dpDateOfBirth"
                        Grid.Row="4"
                        Grid.Column="2"
                        KeyDown="DatePicker_KeyDown"
                        LostFocus="dpDateOfBirth_LostFocus"
                        SelectedDate="{Binding DateOfBirth,
                                               Mode=TwoWay,
                                               ValidatesOnDataErrors=True,
                                               NotifyOnValidationError=True}"
                        Style="{StaticResource DatePickerStyle}" />
        <sdk:DescriptionViewer Grid.Row="4"
                               Grid.Column="3"
                               Width="20"
                               Description="Required"
                               Target="{Binding ElementName=dpDateOfBirth}" />

        <TextBlock x:Name="tbDescription"
                   Grid.Row="5"
                   Grid.Column="1"
                   Style="{StaticResource LabelStyle}"
                   Text="Description:" />

        <TextBox Grid.Row="5"
                 Grid.Column="2"
                 Style="{StaticResource TextBoxStyle}"
                 Text="{Binding Description}" />

        <sdk:DescriptionViewer Grid.Row="5"
                               Grid.Column="3"
                               Width="20"
                               Description="Optional"
                               Target="{Binding ElementName=tbDescription}" />

        <StackPanel Grid.Row="6"
                    Grid.Column="2"
                    HorizontalAlignment="Right"
                    Orientation="Horizontal">
            <Button Command="{Binding OkCommand}"
                    Content="OK"
                    Style="{StaticResource ButtonStyle}" />
            <Button Command="{Binding CancelCommand}"
                    Content="Cancel"
                    Style="{StaticResource ButtonStyle}" />
        </StackPanel>

        <sdk:ValidationSummary Grid.Row="7"
                               Grid.Column="1"
                               Grid.ColumnSpan="2" />

    </Grid>
</UserControl>