<UserControl xmlns="https://github.com/avaloniaui"
             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:views="clr-namespace:LibationAvalonia.Views"
			 xmlns:controls="clr-namespace:LibationAvalonia.Controls"
             mc:Ignorable="d" d:DesignWidth="1560" d:DesignHeight="400"
             x:Class="LibationAvalonia.Views.ProductsDisplay">

	<Grid>

		<DataGrid
			CopyingRowClipboardContent="DataGrid_CopyToClipboard"
			Name="productsGrid"
			GridLinesVisibility="All"
			AutoGenerateColumns="False"
			Items="{Binding GridEntries}"
			Sorting="ProductsGrid_Sorting"
			CanUserSortColumns="True"			
			CanUserReorderColumns="True">

			<DataGrid.Columns>

				<controls:DataGridCheckBoxColumnExt
					PropertyChanged="RemoveColumn_PropertyChanged"
					IsVisible="{Binding RemoveColumnVisivle}"
					Header="Remove"
					IsThreeState="True"
					IsReadOnly="False"
					CanUserSort="True"
					Binding="{Binding Remove, Mode=TwoWay}"
					Width="70" SortMemberPath="Remove" />

				<DataGridTemplateColumn CanUserSort="True" Width="75" Header="Liberate" SortMemberPath="Liberate">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<StackPanel Orientation="Horizontal">
								<Button Width="75" Height="80" Click="LiberateButton_Click" ToolTip.Tip="{Binding Liberate.ToolTip}">
									<Image Stretch="None" Height="80" Source="{Binding Liberate.Image}" />
								</Button>
							</StackPanel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn CanUserSort="False" Width="80" Header="Cover" SortMemberPath="Cover">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Image Tapped="Cover_Click" Height="80" Source="{Binding Cover}" ToolTip.Tip="Click to see full size" />
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn MinWidth="150" Width="2*" Header="Title" CanUserSort="True" SortMemberPath="Title">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border Background="{Binding BackgroundBrush}" BorderThickness="3" Height="80">
									<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Title}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn MinWidth="80" Width="1*" Header="Authors" CanUserSort="True" SortMemberPath="Authors">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border BorderThickness="3" Height="80">
									<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Authors}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn MinWidth="80" Width="1*"  Header="Narrators" CanUserSort="True" SortMemberPath="Narrators">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border BorderThickness="3" Height="80">
									<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Narrators}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn Width="90"  Header="Length" CanUserSort="True" SortMemberPath="Length">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border BorderThickness="3" Height="80">
									<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Length}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn MinWidth="80" Width="1*" Header="Series" CanUserSort="True" SortMemberPath="Series">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border BorderThickness="3" Height="80">
									<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Series}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn MinWidth="100" Width="1*" Header="Description" CanUserSort="True" SortMemberPath="Description">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border BorderThickness="3" Height="80">
									<TextBlock Tapped="Description_Click" VerticalAlignment="Center" TextWrapping="Wrap" ToolTip.Tip="Click to see full description" Text="{Binding Description}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn Width="100" Header="Category" CanUserSort="True" SortMemberPath="Category">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border BorderThickness="3" Height="80">
									<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Category}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn Width="120" Header="Product&#xA;Rating" CanUserSort="True" SortMemberPath="ProductRating">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border BorderThickness="3" Height="80">
									<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" FontSize="11" Text="{Binding ProductRating}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn Width="90" Header="Purchase&#xA;Date" CanUserSort="True" SortMemberPath="PurchaseDate">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border BorderThickness="3" Height="80">
									<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding PurchaseDate}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn Width="120" Header="My Rating" CanUserSort="True" SortMemberPath="MyRating">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border BorderThickness="3" Height="80">
									<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" FontSize="11" Text="{Binding MyRating}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn Width="135" Header="Misc" CanUserSort="True" SortMemberPath="Misc">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Panel Background="{Binding BackgroundBrush}">
								<Border BorderThickness="3" Height="80">
									<TextBlock VerticalAlignment="Center" TextWrapping="WrapWithOverflow" FontSize="10" Text="{Binding Misc}" />
								</Border>
							</Panel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn CanUserSort="True" Width="100" Header="Tags" SortMemberPath="BookTags">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<StackPanel Orientation="Horizontal">
								<Button IsVisible="{Binding !IsSeries}" Width="100" Height="80" Click="OnTagsButtonClick" ToolTip.Tip="Click to edit tags" >
									<Panel>
										<Image IsVisible="{Binding !BookTags.HasTags}" Stretch="None" Source="/Assets/edit_25x25.png" />
										<TextBlock IsVisible="{Binding BookTags.HasTags}" FontSize="12" TextWrapping="WrapWithOverflow" Text="{Binding BookTags.Tags}"/>
									</Panel>
								</Button>
							</StackPanel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

			</DataGrid.Columns>
		</DataGrid>

	</Grid>
</UserControl>
