<UserControl x:Class="RowDetailsInTooltip.MainPage"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
			 xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
			 xmlns:grid="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
			 xmlns:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView">

	<UserControl.Resources>

		<telerik:Office_BlackTheme x:Key="Theme" />

		<LinearGradientBrush x:Key="GridViewRowSelectedBackground" EndPoint="0.5,1" StartPoint="0.5,0">
			<GradientStop Color="#FFFFCA5D" Offset="1"/>
			<GradientStop Color="#FFFFDC9C" Offset="0"/>
		</LinearGradientBrush>
		<LinearGradientBrush x:Key="GridViewInvalidBackground" EndPoint="0.5,1" StartPoint="0.5,0">
			<GradientStop Color="#FFFCDCDC"/>
			<GradientStop Color="#FFFCC1C1" Offset="1"/>
		</LinearGradientBrush>
		<SolidColorBrush x:Key="GridViewRowIndicatorBackground" Color="#FFDBDEE1" />
		<LinearGradientBrush x:Key="GridViewIndicatorsPartsFill" EndPoint="0.5,1" StartPoint="0.5,0">
			<GradientStop Color="#FF000000" Offset="0"/>
			<GradientStop Color="#FF000000" Offset="1"/>
		</LinearGradientBrush>
		<SolidColorBrush x:Key="GridViewRowNormalBackground" Color="#FFFFFFFF" />
		<SolidColorBrush x:Key="GridLinesFill" Color="#FFB3B3B3" />
		<SolidColorBrush x:Key="GridViewForeground" Color="#FF000000" />
		<SolidColorBrush x:Key="GridViewRowInnerBorderBackground_Alternate" Color="#FFF4F4F4" />

		<telerik:BooleanToOpacityConverter x:Key="BooleanToOpacityConverter" />
		<telerik:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
		<grid:GridLineWidthToThicknessConverter x:Key="GridLineWidthToThicknessConverter" />

		<Style x:Key="ToolTipStyle" TargetType="ToolTip">
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="Padding" Value="0"/>
			<Setter Property="BorderThickness" Value="0"/>
			<Setter Property="BorderBrush" Value="Transparent" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ToolTip">
						<Border x:Name="Root" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
							<Border Background="{TemplateBinding Background}" BorderThickness="1" CornerRadius="1" Padding="{TemplateBinding Padding}">
								<Border.Resources>
									<Storyboard x:Key="Visible State"/>
									<Storyboard x:Key="Normal State"/>
								</Border.Resources>
								<ContentPresenter Cursor="{TemplateBinding Cursor}" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
							</Border>
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

		<ControlTemplate x:Key="GridViewRowTemplate" TargetType="grid:GridViewRow">
			<grid:SelectiveScrollingGrid x:Name="grid">

				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="*" />
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="*" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>


				<vsm:VisualStateManager.VisualStateGroups>
					<vsm:VisualStateGroup x:Name="FocusStates">
						<vsm:VisualState x:Name="Unfocused" />
						<vsm:VisualState x:Name="Focused">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetName="NavigatorIndicator" 
															   Storyboard.TargetProperty="Visibility">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible" />
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</vsm:VisualState>
					</vsm:VisualStateGroup>
					<vsm:VisualStateGroup x:Name="SelectionStates">
						<vsm:VisualState x:Name="Unselected" />
					</vsm:VisualStateGroup>
					<vsm:VisualStateGroup x:Name="CommonStates">
						<vsm:VisualState x:Name="Normal" />
						<vsm:VisualState x:Name="MouseOver">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundRectangle"
															   Storyboard.TargetProperty="Opacity">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value=".5" />
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</vsm:VisualState>
						<vsm:VisualState x:Name="Selected">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundRectangle" 
															   Storyboard.TargetProperty="Opacity">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="1" />
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</vsm:VisualState>
					</vsm:VisualStateGroup>
					<vsm:VisualStateGroup x:Name="ValueStates">
						<vsm:VisualState x:Name="Valid" />
						<vsm:VisualState x:Name="Invalid">
							<Storyboard>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetName="InvalidBorder" 
															   Storyboard.TargetProperty="Opacity">
									<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="1" />
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</vsm:VisualState>
					</vsm:VisualStateGroup>
				</vsm:VisualStateManager.VisualStateGroups>

				<Border x:Name="SelectionBackground"
						Grid.Column="2"
						Grid.ColumnSpan="2"
						MinHeight="{TemplateBinding MinHeight}"
						Background="{TemplateBinding Background}"
						Margin="{TemplateBinding Margin}"
						Padding="{TemplateBinding Padding}"
						BorderThickness="0"
						BorderBrush="{x:Null}" />

				<Rectangle x:Name="BackgroundRectangle"
						   Grid.Column="2"
						   Grid.ColumnSpan="2"
						   Opacity="0"
						   Fill="{StaticResource GridViewRowSelectedBackground}" />

				<Rectangle x:Name="InvalidBorder"
						   Grid.Column="2" Grid.ColumnSpan="2"  
						   Opacity="0"
						   Fill="{StaticResource GridViewInvalidBackground}" />

				<controls:GridViewToggleButton Grid.Column="2"
											   Width="24"
											   MinHeight="24"
											   grid:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
											   Opacity="{Binding IsExpandable, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToOpacityConverter}}"
											   IsHitTestVisible="{Binding IsExpandable, RelativeSource={RelativeSource TemplatedParent}}"
											   Visibility="{Binding HasHierarchy, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}"
											   IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />

				<Border Grid.Column="2"
						BorderBrush="{TemplateBinding VerticalGridLinesBrush}"
						BorderThickness="{Binding VerticalGridLinesWidth, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource GridLineWidthToThicknessConverter}, ConverterParameter=Right}"
						grid:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
						Visibility="{Binding HasHierarchy, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />

				<grid:DataCellsPresenter Grid.Column="3"
										 telerik:StyleManager.Theme="{StaticResource Theme}"
										 x:Name="PART_DataCellsPresenter" />

				<ContentPresenter x:Name="PART_HierarchyChildPresenter" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2"
								  Visibility="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />

				<Border x:Name="PART_RowBorder"
						Background="Transparent"
						BorderBrush="{TemplateBinding HorizontalGridLinesBrush}"
						BorderThickness="{Binding HorizontalGridLinesWidth, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource GridLineWidthToThicknessConverter}, ConverterParameter=Bottom}"
						Grid.ColumnSpan="4" Grid.Column="1" Grid.RowSpan="4" VerticalAlignment="Stretch">
					
					<ToolTipService.ToolTip>
						<ToolTip Style="{StaticResource ToolTipStyle}" 
								 Opened="OnToolTipOpened"
								 Closed="OnToolTipClosed">							
							<grid:DetailsPresenter 
								x:Name="PART_DetailsPresenter" 
								DetailsProvider="{Binding DetailsProvider, RelativeSource={RelativeSource TemplatedParent}}" 
								telerik:StyleManager.Theme="{StaticResource Theme}"/>
						</ToolTip>
					</ToolTipService.ToolTip>
					
				</Border>

				<grid:IndentPresenter x:Name="PART_IndentPresenter"
									  telerik:StyleManager.Theme="{StaticResource Theme}"
									  IndentLevel="{TemplateBinding IndentLevel}"
									  Grid.Column="1" Grid.RowSpan="4"
									  Background="{TemplateBinding Background}"
									  grid:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" />

				<Border x:Name="PART_IndicatorPresenter"
						Width="24"
						VerticalAlignment="Stretch"
						Grid.Column="0"
						Visibility="{TemplateBinding RowIndicatorVisibility}"
						grid:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
						Background="{StaticResource GridViewRowIndicatorBackground}"
						Grid.RowSpan="3"
						BorderBrush="{TemplateBinding BorderBrush}"
						BorderThickness="0,0,1,1">

					<Path x:Name="NavigatorIndicator"
						  Fill="{StaticResource GridViewIndicatorsPartsFill}"
						  Stretch="Fill"
						  VerticalAlignment="Center"
						  HorizontalAlignment="Center"
						  Width="5"
						  Height="8"
						  Data="M254.5,183.75 L254.5,193.33333 260.75,188.16682 z"
						  Visibility="Collapsed" />

				</Border>

			</grid:SelectiveScrollingGrid>

		</ControlTemplate>

		<Style x:Key="GridViewRowStyle" TargetType="grid:GridViewRow">
			<Setter Property="IsTabStop" Value="False" />
			<Setter Property="Template" Value="{StaticResource GridViewRowTemplate}" />
			<Setter Property="Background" Value="{StaticResource GridViewRowNormalBackground}" />
			<Setter Property="BorderBrush" Value="{StaticResource GridLinesFill}" />
			<Setter Property="MinHeight" Value="24" />
			<Setter Property="FontWeight" Value="Normal" />
			<Setter Property="Foreground" Value="{StaticResource GridViewForeground}" />
		</Style>
	</UserControl.Resources>

	<Grid>
		
		<Grid.Resources>
			<DataTemplate x:Key="RowDetailsTemplate">
				<controls:RadGridView Name="playersGrid" 
									  ItemsSource="{Binding Players}"
									  AutoGenerateColumns="False"
									  ColumnWidth="Auto"
									  Width="Auto"
									  ColumnBackground="{x:Null}"
									  Margin="1"
									  BorderThickness="1,1,0,0"
									  IsFilteringAllowed="False"
									  ShowGroupPanel="False"
									  CanUserFreezeColumns="False"
									  CanUserReorderColumns="False"
									  CanUserResizeColumns="False"
									  RowIndicatorVisibility="Collapsed"
									  HorizontalAlignment="Left"
									  VerticalAlignment="Top">
					<controls:RadGridView.Columns>
						<controls:GridViewDataColumn Header="Name" 
													 DataMemberBinding="{Binding Name}"/>
						<controls:GridViewDataColumn Header="#" 
													 DataMemberBinding="{Binding Number}"/>
						<controls:GridViewDataColumn Header="Pos." 
													 DataMemberBinding="{Binding Position}"/>
						<controls:GridViewDataColumn Header="Country" 
													 DataMemberBinding="{Binding Country}"/>
					</controls:RadGridView.Columns>
				</controls:RadGridView>
			</DataTemplate>
		</Grid.Resources>
		
		<controls:RadGridView Name="clubsGrid" 
							  Margin="2"
							  BorderThickness="1,1,0,0"
							  RowStyle="{StaticResource GridViewRowStyle}"
							  ItemsSource="{Binding Clubs}"
							  RowDetailsTemplate="{StaticResource RowDetailsTemplate}"
							  AutoGenerateColumns="False"
							  ColumnWidth="Auto"
							  Width="Auto"
							  ColumnBackground="{x:Null}"
							  IsFilteringAllowed="False"
							  ShowGroupPanel="False"
							  CanUserFreezeColumns="False"
							  CanUserReorderColumns="False"
							  CanUserResizeColumns="False"
							  RowIndicatorVisibility="Collapsed"
							  HorizontalAlignment="Left"
							  VerticalAlignment="Top">
			<controls:RadGridView.Columns>
				<controls:GridViewDataColumn Header="Name" 
											 DataMemberBinding="{Binding Name}"/>
				<controls:GridViewDataColumn Header="Est." 
											 DataMemberBinding="{Binding Established}"
											 DataFormatString="{}{0:yyyy}"/>
				<controls:GridViewDataColumn Header="Stadium"
											 DataMemberBinding="{Binding StadiumCapacity}" 
											 DataFormatString="{}{0:N0}"/>
			</controls:RadGridView.Columns>
		</controls:RadGridView>
	</Grid>
</UserControl>
