<?xml version="1.0" encoding="utf-8"?>
<UserControl x:Class="Validation.MainPage" mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="600" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Grid.Resources>
            <Style x:Key="_errorFrame" TargetType="Border">
                <Setter Property="Background" Value="#f0f7dbdb" />
                <Setter Property="BorderBrush" Value="#ffdb000c" />
                <Setter Property="CornerRadius" Value="2" />
            </Style>
        </Grid.Resources>
        
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="Silverlight Validation" FontSize="14" FontWeight="Bold" />
        </StackPanel>
        
        <sdk:TabControl Name="tabControl1" Grid.Row="1">
            
            <sdk:TabItem Header="Throw on Setters">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock Text="C1FlexGrid" FontSize="14" />
                    <c1:C1FlexGrid Name="_flexThrow" Grid.Row="1" />

                    <TextBlock Text="MSDataGrid" FontSize="14" Grid.Row="2" />
                    <sdk:DataGrid Name="_msThrow" Grid.Row="3" />

                    <Border Grid.Row="4" Background="LightGoldenrodYellow">
                        <TextBlock TextWrapping="Wrap" Margin="4">
                        The simplest validation method is simply to throw exceptions when a property
                        setter is passed an invalid value. This method allows for property-level 
                        validation only (no item-level validation).
                        To see some errors, try setting the Price to a negative value.
                        </TextBlock>
                    </Border>
                </Grid>
            </sdk:TabItem>
            
            <sdk:TabItem Header="IDataErrorInfo">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock Text="C1FlexGrid" FontSize="14" />
                    <c1:C1FlexGrid Name="_flexDei" Grid.Row="1" />

                    <TextBlock Text="MSDataGrid" FontSize="14" Grid.Row="2" />
                    <sdk:DataGrid Name="_msDei" Grid.Row="3" />

                    <Border Grid.Row="4" Background="LightGoldenrodYellow">
                        <TextBlock TextWrapping="Wrap" Margin="4">
                        Data items that implement the IDataErrorInfo interface can perform validation
                        at a property level (by returning an error string from their default indexer)
                        and at item level (by returning an error string from their Error property).
                        To see some item-level errors, try setting the Price to a value lower than the Cost.
                        To see property-level errors, try setting the Price to a negative value.
                        </TextBlock>
                    </Border>
                </Grid>
            </sdk:TabItem>
            
            <sdk:TabItem Header="INotifyDataErrorInfo">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock Text="C1FlexGrid" FontSize="14" />
                    <c1:C1FlexGrid Name="_flexNdei" Grid.Row="1" />

                    <TextBlock Text="MSDataGrid" FontSize="14" Grid.Row="2" />
                    <sdk:DataGrid Name="_msNdei" Grid.Row="3" />

                    <Border Grid.Row="4" Background="LightGoldenrodYellow">
                        <TextBlock TextWrapping="Wrap" Margin="4">
                        Data items that implement the INotifyDataErrorInfo interface can perform validation
                        at a property level and at item level. The main difference between the IDataErrorInfo 
                        and INotifyDataErrorInfo is that the latter raises an event when errors are detected,
                        allowing them to perform validation asynchronously.
                        </TextBlock>
                    </Border>
                </Grid>
            </sdk:TabItem>
            
            <sdk:TabItem Header="Validation Attributes">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock Text="C1FlexGrid" FontSize="14" />
                    <c1:C1FlexGrid Name="_flexAttributes" Grid.Row="1" />

                    <TextBlock Text="MSDataGrid" FontSize="14" Grid.Row="2" />
                    <sdk:DataGrid Name="_msAttributes" Grid.Row="3" />

                    <Border Grid.Row="4" Background="LightGoldenrodYellow">
                        <TextBlock TextWrapping="Wrap" Margin="4">
                        Data items can use data annotations to perform validation in a declarative manner.
                        Custom validators can be used to perform item-level validation.
                        </TextBlock>
                    </Border>
                </Grid>
            </sdk:TabItem>
        </sdk:TabControl>
    </Grid>
</UserControl>