<?xml version="1.0" encoding="utf-8"?>
<UserControl x:Class="C1DataGrid_Ria.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:ria="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:common="clr-namespace:SamplesCommon;assembly=SamplesCommon.5" xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" xmlns:local="clr-namespace:C1DataGrid_Ria2010Web">
	<Grid x:Name="LayoutRoot" Background="White">
		<Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<!-- RIA Data Source -->
        <c1:C1RiaAdapter x:Name="_adapter" DataGrid="{Binding ElementName=_dataGrid}" InteractionMode="Prompt">
			<ria:DomainDataSource x:Name="_myDataSource" QueryName="GetProducts" SubmittedChanges="SubmitCompleted" PageSize="8">
				<ria:DomainDataSource.DomainContext>
					<local:NorthwindContext />
				</ria:DomainDataSource.DomainContext>
				<ria:DomainDataSource.GroupDescriptors>
					<ria:GroupDescriptor PropertyPath="CategoryID" />
					<ria:GroupDescriptor PropertyPath="Discontinued" />
				</ria:DomainDataSource.GroupDescriptors>
				<ria:DomainDataSource.SortDescriptors>
					<ria:SortDescriptor PropertyPath="ProductName" Direction="Descending" />
				</ria:DomainDataSource.SortDescriptors>
				<ria:DomainDataSource.FilterDescriptors>
					<ria:FilterDescriptor PropertyPath="UnitPrice" Operator="IsGreaterThanOrEqualTo" Value="18" />
					<ria:FilterDescriptor PropertyPath="ProductName" Operator="Contains" Value="C" />
				</ria:DomainDataSource.FilterDescriptors>
			</ria:DomainDataSource>
        </c1:C1RiaAdapter>

        <!-- Header -->
		<Border Grid.Row="0" Height="40" Background="LightBlue">
			<TextBlock Text="CollectionView adapter for C1DataGrid: RIA Services" Margin="10 0 0 0" FontSize="15" FontWeight="Bold" VerticalAlignment="Center" />
		</Border>
        
        <!-- Localization -->
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Stretch" Margin="8 10 0 0">
            <TextBlock Text="Language" TextWrapping="Wrap" TextAlignment="Center" VerticalAlignment="Center" Margin="8,0,0,0" />
            <common:LocalizationComboBox Height="22" Width="150" Margin="4,0,0,0" />
        </StackPanel>
        
		<!-- Content -->
		<Grid Grid.Row="2" Margin="20 0 20 20">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="*" />
			</Grid.RowDefinitions>

			<!-- DataPager -->
			<data:DataPager x:Name="_dataPager" Source="{Binding Data, ElementName=_myDataSource}" BorderThickness="0" Background="White" />

			<!-- C1DataGrid -->
            <c1:C1DataGrid x:Name="_dataGrid" CanUserGroup="True" AutoGenerateColumns="False" Grid.Row="1" CanUserAddRows="True" CanUserEditRows="True" CanUserRemoveRows="True" ItemsSource="{Binding Data, ElementName=_adapter}" BeginningRowEdit="_dataGrid_BeginningRowEdit" CommittingRowEdit="_dataGrid_CommittingRowEdit" CancelingRowEdit="_dataGrid_CancelingRowEdit" RowsDeleted="_dataGrid_RowsDeleted">
                <c1:C1DataGrid.Columns>
                    <c1:DataGridNumericColumn Binding="{Binding CategoryID, Mode=TwoWay}" SortMemberPath="CategoryID" FilterMemberPath="CategoryID" Header="CategoryID" />
                    <c1:DataGridCheckBoxColumn Binding="{Binding Discontinued, Mode=TwoWay}" SortMemberPath="Discontinued" FilterMemberPath="Discontinued" Header="Discontinued" />
                    <c1:DataGridTextColumn Binding="{Binding ProductName, Mode=TwoWay}" SortMemberPath="ProductName" FilterMemberPath="ProductName" Header="ProductName" />
                    <c1:DataGridTextColumn Binding="{Binding QuantityPerUnit, Mode=TwoWay}" SortMemberPath="QuantityPerUnit" FilterMemberPath="QuantityPerUnit" Header="QtyPerUnit" />
                    <c1:DataGridNumericColumn Binding="{Binding UnitPrice, Mode=TwoWay}" SortMemberPath="UnitPrice" FilterMemberPath="UnitPrice" Header="UnitPrice" />
                </c1:C1DataGrid.Columns>
            </c1:C1DataGrid>

			<!-- Change Text -->
			<TextBox x:Name="_changeText" Margin="0 4 0 0" Grid.Row="2" />

			<!-- Reject Button -->
			<Button x:Name="_rejectButton" Content="Reject Changes" IsEnabled="False" Click="_rejectButton_Click" Width="120" HorizontalAlignment="Right" Margin="0 4 130 0" Grid.Row="3" />

			<!-- Submit Button -->
			<Button x:Name="_submitButton" Content="Submit Changes" IsEnabled="False" Click="_submitButton_Click" Width="120" HorizontalAlignment="Right" Margin="0 4 0 0" Grid.Row="3" />
		</Grid>
	</Grid>
</UserControl>