<UserControl 
    x:Class="CellBorderTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:my="clr-namespace:CellBorderTest"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	 xmlns:local="clr-namespace:CellBorderTest"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="700" d:DesignWidth="1000" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    Loaded="UserControl_Loaded">
	<UserControl.Resources>
		<telerik:GridLineWidthToThicknessConverter x:Key="GridLineWidthToThicknessConverter"/>
		<SolidColorBrush x:Key="ItemOuterBorder_Over" Color="#FFFFC92B"/>
		<SolidColorBrush x:Key="ItemInnerBorder_Over" Color="White"/>
		<LinearGradientBrush x:Key="ItemBackground_Over" EndPoint="0.5,1" StartPoint="0.5,0">
			<GradientStop Color="#FFFFFBA3" Offset="1"/>
			<GradientStop Color="#FFFFFBDA" Offset="0"/>
		</LinearGradientBrush>
		<SolidColorBrush x:Key="ItemOuterBorder_Selected" Color="#FFFFC92B"/>
		<SolidColorBrush x:Key="ItemInnerBorder_Selected" Color="White"/>
		<LinearGradientBrush x:Key="ItemBackground_Selected" EndPoint="0.5,1" StartPoint="0.5,0">
			<GradientStop Color="#FFFCE79F" Offset="1"/>
			<GradientStop Color="#FFFDD3A8"/>
		</LinearGradientBrush>
		<SolidColorBrush x:Key="ControlOuterBorder" Color="#FF848484"/>
		<SolidColorBrush x:Key="ControlOuterBorder_Invalid" Color="#FFDB000C"/>
		<SolidColorBrush x:Key="ItemBackground" Color="White"/>
		<SolidColorBrush x:Key="ControlInnerBorder_Invalid" Color="White"/>
		<ControlTemplate x:Key="ValidationToolTipTemplate" TargetType="ToolTip">
			<Grid x:Name="Root" Margin="5,0" Opacity="0" RenderTransformOrigin="0,0">
				<Grid.RenderTransform>
					<TranslateTransform x:Name="xform" X="-25"/>
				</Grid.RenderTransform>
				<VisualStateManager.VisualStateGroups>
					<VisualStateGroup x:Name="OpenStates">
						<VisualStateGroup.Transitions>
							<VisualTransition GeneratedDuration="0"/>
							<VisualTransition GeneratedDuration="0:0:0.2" To="Open">
								<Storyboard>
									<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="X" Storyboard.TargetName="xform">
										<SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
									</DoubleAnimationUsingKeyFrames>
									<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root">
										<SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
									</DoubleAnimationUsingKeyFrames>
								</Storyboard>
							</VisualTransition>
						</VisualStateGroup.Transitions>
						<VisualState x:Name="Closed">
							<Storyboard>
								<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root">
									<SplineDoubleKeyFrame KeyTime="0" Value="0"/>
								</DoubleAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
						<VisualState x:Name="Open">
							<Storyboard>
								<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="X" Storyboard.TargetName="xform">
									<SplineDoubleKeyFrame KeyTime="0" Value="0"/>
								</DoubleAnimationUsingKeyFrames>
								<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root">
									<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
								</DoubleAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
					</VisualStateGroup>
				</VisualStateManager.VisualStateGroups>
				<Border Background="#052A2E31" CornerRadius="5" Margin="4,4,-4,-4"/>
				<Border Background="#152A2E31" CornerRadius="4" Margin="3,3,-3,-3"/>
				<Border Background="#252A2E31" CornerRadius="3" Margin="2,2,-2,-2"/>
				<Border Background="#352A2E31" CornerRadius="2" Margin="1,1,-1,-1"/>
				<Border Background="#FFDC000C" CornerRadius="2"/>
				<Border CornerRadius="2">
					<ItemsControl ItemsSource="{TemplateBinding Content}">
						<ItemsControl.ItemsPanel>
							<ItemsPanelTemplate>
								<StackPanel/>
							</ItemsPanelTemplate>
						</ItemsControl.ItemsPanel>
						<ItemsControl.ItemTemplate>
							<DataTemplate>
								<TextBlock Foreground="White" MaxWidth="250" Margin="8,4,8,4" TextWrapping="Wrap" Text="{Binding}"/>
							</DataTemplate>
						</ItemsControl.ItemTemplate>
					</ItemsControl>
				</Border>
			</Grid>
		</ControlTemplate>
		<SolidColorBrush x:Key="ItemOuterBorder_Invalid" Color="#FFCE7D7D"/>
		<LinearGradientBrush x:Key="ItemInnerBorder_Invalid" EndPoint="0.5,1" StartPoint="0.5,0">
			<GradientStop Color="#FFEBF4FD"/>
			<GradientStop Color="#FFDBEAFD" Offset="1"/>
		</LinearGradientBrush>
		<LinearGradientBrush x:Key="ItemBackground_Invalid" EndPoint="0.5,1" StartPoint="0.5,0">
			<GradientStop Color="#FFFCDCDC"/>
			<GradientStop Color="#FFFCC1C1" Offset="1"/>
		</LinearGradientBrush>
		<SolidColorBrush x:Key="ItemInnerBorder_Disabled" Color="#FFF8F8F8"/>
		<SolidColorBrush x:Key="ItemBackground_Disabled" Color="#FFE0E0E0"/>
		<SolidColorBrush x:Key="GridView_CellBackground_Edited" Color="#FFFFFFFF"/>
		<ControlTemplate x:Key="GridViewCellTemplate" TargetType="telerik:GridViewCell">
			<Grid>
				<VisualStateManager.VisualStateGroups>
					<VisualStateGroup x:Name="SelectionStates">
						<VisualState x:Name="Unselected"/>
						<VisualState x:Name="Selected">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Selected">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
					</VisualStateGroup>
					<VisualStateGroup x:Name="CommonStates">
						<VisualState x:Name="Normal"/>
						<VisualState x:Name="Current">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Current">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
						<VisualState x:Name="MouseOver">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Over">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
					</VisualStateGroup>
					<VisualStateGroup x:Name="EditingStates">
						<VisualState x:Name="Edited">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="PART_ContentPresenter">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0"/>
								</ObjectAnimationUsingKeyFrames>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="VerticalAlignment" Storyboard.TargetName="PART_ContentPresenter">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Stretch"/>
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
						<VisualState x:Name="Display"/>
					</VisualStateGroup>
					<VisualStateGroup x:Name="DisabledStates">
						<VisualState x:Name="Enabled"/>
						<VisualState x:Name="Disabled">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_CellBorder">
									<DiscreteObjectKeyFrame KeyTime="0" Value="0.4"/>
								</ObjectAnimationUsingKeyFrames>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_ContentPresenter">
									<DiscreteObjectKeyFrame KeyTime="0" Value="0.7"/>
								</ObjectAnimationUsingKeyFrames>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Disabled">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
					</VisualStateGroup>
					<VisualStateGroup x:Name="ValueStates">
						<VisualState x:Name="Valid"/>
						<VisualState x:Name="Invalid">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Invalid">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
						<VisualState x:Name="InvalidUnfocused">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Invalid_Unfocused">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
					</VisualStateGroup>
				</VisualStateManager.VisualStateGroups>
				<Border x:Name="PART_CellBorder" BorderThickness="{TemplateBinding BorderThickness}" Background="Yellow" BorderBrush="#FFE90F0F"/>
				<Border x:Name="Background_Over" BorderBrush="{StaticResource ItemOuterBorder_Over}" BorderThickness="1" Grid.ColumnSpan="2" Grid.Column="2" CornerRadius="1" Margin="1,1,2,2" Visibility="Collapsed">
					<Border BorderBrush="{StaticResource ItemInnerBorder_Over}" BorderThickness="1" Background="{StaticResource ItemBackground_Over}"/>
				</Border>
				<Border x:Name="Background_Selected" BorderBrush="{StaticResource ItemOuterBorder_Selected}" BorderThickness="1" Grid.ColumnSpan="2" Grid.Column="2" CornerRadius="1" Margin="1,1,2,2" Visibility="Collapsed">
					<Border BorderBrush="{StaticResource ItemInnerBorder_Selected}" BorderThickness="1" Background="{StaticResource ItemBackground_Selected}"/>
				</Border>
				<Border x:Name="Background_Current" BorderBrush="{StaticResource ControlOuterBorder}" BorderThickness="1" Grid.ColumnSpan="2" Grid.Column="2" CornerRadius="1" Margin="1,1,2,2" Visibility="Collapsed"/>
				<Border x:Name="Background_Invalid" BorderBrush="{StaticResource ControlOuterBorder_Invalid}" BorderThickness="1" Background="{StaticResource ItemBackground}" Grid.ColumnSpan="2" Grid.Column="2" CornerRadius="1" Margin="1,1,2,2" Visibility="Collapsed">
					<ToolTipService.ToolTip>
						<ToolTip x:Name="validationTooltip" Content="{TemplateBinding Errors}" Placement="Right" Template="{StaticResource ValidationToolTipTemplate}"/>
					</ToolTipService.ToolTip>
					<Grid Background="Transparent" HorizontalAlignment="Right" Height="12" Margin="1,-4,-4,0" VerticalAlignment="Top" Width="12">
						<Path Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" Fill="{StaticResource ControlOuterBorder_Invalid}" Margin="1,3,0,0"/>
						<Path Data="M 0,0 L2,0 L 8,6 L8,8" Fill="{StaticResource ControlInnerBorder_Invalid}" Margin="1,3,0,0"/>
					</Grid>
				</Border>
				<Border x:Name="Background_Invalid_Unfocused" BorderBrush="{StaticResource ItemOuterBorder_Invalid}" BorderThickness="1" Grid.ColumnSpan="2" Grid.Column="2" CornerRadius="1" Margin="1,1,1,2" Opacity="1" Visibility="Collapsed">
					<Border BorderBrush="{StaticResource ItemInnerBorder_Invalid}" BorderThickness="1" Background="{StaticResource ItemBackground_Invalid}"/>
				</Border>
				<Border x:Name="Background_Disabled" BorderBrush="{StaticResource ItemInnerBorder_Disabled}" BorderThickness="1" Background="{StaticResource ItemBackground_Disabled}" Grid.ColumnSpan="2" Grid.Column="2" Margin="0,0,1,1" Visibility="Collapsed"/>
				<ContentPresenter x:Name="PART_ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
			</Grid>
		</ControlTemplate>
		<SolidColorBrush x:Key="GridView_GridLinesItemBorder" Color="Red"/>
		<local:MyStyleSelector x:Key="styleSelector">
			<local:MyStyleSelector.LeagueStyle>
				<Style  TargetType="telerik:GridViewCell">
					<Setter Property="Template" Value="{StaticResource GridViewCellTemplate}"/>
					<Setter Property="Padding" Value="5,0,3,0"/>
					<Setter Property="BorderBrush" Value="{StaticResource GridView_GridLinesItemBorder}"/>
					<Setter Property="BorderThickness" Value="4"/>
					<Setter Property="VerticalContentAlignment" Value="Center"/>
					<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
					<Setter Property="Background" Value="Yellow"/>
				</Style>
			</local:MyStyleSelector.LeagueStyle>
		</local:MyStyleSelector>
	</UserControl.Resources>
	<Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadGridView 
            Name="radGridView1" AutoGenerateColumns="False"
            SelectionUnit="Cell" SelectionMode="Extended"
            Height="500" Width="800" />
    </Grid>
</UserControl>
