<UserControl x:Class="SilverlightApplication1.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
	xmlns:e="clr-namespace:SilverlightApplication1.Web.Services"
	xmlns:my="clr-namespace:SilverlightApplication1"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
	<UserControl.Resources>
		<my:CustomersViewModel x:Key="CustomersViewModel"/>
	</UserControl.Resources>
	<Grid DataContext="{StaticResource CustomersViewModel}">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="250"/>
		</Grid.ColumnDefinitions>
		<Grid Name="mainGrid" Grid.Column="0">
			<Grid.RowDefinitions>
				<RowDefinition Height="*" />
				<RowDefinition Height="Auto" />
			</Grid.RowDefinitions>
			<telerik:RadGridView 
				x:Name="radGridView" 
				Grid.Row="0"
				ItemsSource="{Binding View}"
				IsBusy="{Binding IsBusy}"
				ShowGroupPanel="False"
				RowIndicatorVisibility="Collapsed"
				IsFilteringAllowed="False"
				CanUserSortColumns="False"
				AutoGenerateColumns="False"
				IsReadOnly="True">
				<telerik:RadGridView.Columns>
					<telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
					<telerik:GridViewDataColumn DataMemberBinding="{Binding City}"/>
					<telerik:GridViewDataColumn DataMemberBinding="{Binding ContactName}" Header="Contact"/>
					<telerik:GridViewDataColumn DataMemberBinding="{Binding ContactTitle}" Header="Title"/>
					<telerik:GridViewDataColumn DataMemberBinding="{Binding CompanyName}" Header="Company"/>
				</telerik:RadGridView.Columns>
			</telerik:RadGridView>
			<telerik:RadDataPager x:Name="radDataPager" 
								  Grid.Row="1" 
								  Margin="0, 0, 0, 1"
								  Source="{Binding View}" 
								  DisplayMode="All"
								  IsTotalItemCountFixed="True"/>
		</Grid>
		<StackPanel Grid.Column="1" Margin="3">

			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition/>
					<RowDefinition/>
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition/>
					<ColumnDefinition/>
				</Grid.ColumnDefinitions>
				<CheckBox Content="Auto" 
						  Margin="1"
						  VerticalAlignment="Center"
						  VerticalContentAlignment="Center" 
						  IsChecked="{Binding AutoLoad, Mode=TwoWay}"/>
				<telerik:RadButton Grid.Column="1" 
								   Content="Refresh"
								   Margin="1"
								   Padding="10,2" 
								   Command="{Binding LoadCommand}"/>
				<TextBlock Grid.Row="1" 
						   Text="Page Size"
						   VerticalAlignment="Center"
						   Margin="1" />
				<telerik:RadNumericUpDown Grid.Row="1" 
										  Grid.Column="1" 
										  Margin="1"
										  Value="{Binding PageSize, Mode=TwoWay}"
										  Minimum="0" 
										  IsInteger="True"/>
			</Grid>

			<TextBlock Text="Sort by" Margin="0,10,0,0" FontWeight="Bold" />
			<TextBlock Text="Country" />
			<RadioButton Content="Ascending" 
						 GroupName="CountrySort"
						 IsChecked="{Binding IsCountryAscendingChecked, Mode=TwoWay}"/>
			<RadioButton Content="Descending" 
						 GroupName="CountrySort"
						 IsChecked="{Binding IsCountryDescendingChecked, Mode=TwoWay}"/>
			<RadioButton Content="None" 
						 GroupName="CountrySort"
						 IsChecked="{Binding IsCountryNoneChecked, Mode=TwoWay}"/>
			<TextBlock Text="Then by" Margin="0,10,0,0" FontWeight="Bold" />
			<TextBlock Text="City" />
			<RadioButton Content="Ascending" 
						 GroupName="CitySort" 
						 IsChecked="{Binding IsCityAscendingChecked, Mode=TwoWay}"/>
			<RadioButton Content="Descending" 
						 GroupName="CitySort"
						 IsChecked="{Binding IsCityDescendingChecked, Mode=TwoWay}"/>
			<RadioButton Content="None" 
						 GroupName="CitySort"
						 IsChecked="{Binding IsCityNoneChecked, Mode=TwoWay}"/>

			<TextBlock Text="Filter by" Margin="0,10,0,0" FontWeight="Bold" />
			<TextBlock Text="Contact Title" Margin="0,5,0,0" />
			<telerik:RadComboBox ItemsSource="{Binding ContactTitles}" 
								 SelectedValue="{Binding SelectedContactTitle, Mode=TwoWay}"/>
		</StackPanel>
	</Grid>
</UserControl>
