<UserControl
  x:Class="NuGet.PackageManagement.UI.DetailControl"
  xmlns:nuget="clr-namespace:NuGet.PackageManagement.UI"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  Background="{Binding UIBrushes.DetailPaneBackground }"
  x:Name="_self"
  mc:Ignorable="d"
  d:DesignHeight="600"
  d:DesignWidth="400">
  <UserControl.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <nuget:SharedResources/>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </UserControl.Resources>
  <UserControl.CommandBindings>
    <CommandBinding
      Command="{x:Static nuget:PackageManagerControlCommands.OpenExternalLink}"
      Executed="ExecuteOpenLicenseLink" />
  </UserControl.CommandBindings>
  <ScrollViewer
    x:Name="_root"
    HorizontalScrollBarVisibility="Disabled">
    <Grid
      Margin="24,0,7,0">
      <Grid.RowDefinitions>
        <RowDefinition
          Height="Auto" />
        <RowDefinition
          Height="{Binding Path=IsSolution, Converter={StaticResource ProjectAndSolutionViewHeightConverter}}"
          MinHeight="{Binding Path=IsSolution, Converter={StaticResource ProjectAndSolutionViewMinHeightConverter}}" />
        <RowDefinition
          Height="Auto" />
        <RowDefinition
          Height="Auto" />
        <RowDefinition
          Height="Auto" />
        <RowDefinition
          Height="Auto" />
      </Grid.RowDefinitions>

      <!-- Icon and Id -->
      <StackPanel
        Grid.Row="0"
        Orientation="Horizontal"
        MinHeight="32"
        Margin="0,8">
        <Image
          Margin="0,0,8,0"
          Style="{StaticResource PackageIconImageStyle}" />
        <TextBox
          Style="{DynamicResource SelectableTextBlockStyle}"
          Text="{Binding Path=Id, Mode=OneWay}"
          FontSize="{Binding ElementName=_self,Path=FontSize,Converter={StaticResource Font155PercentSizeConverter}}" />
      </StackPanel>

      <!-- project action when in project package manager -->
      <nuget:ProjectView
        Grid.Row="1"
        Margin="0,8"
        InstallButtonClicked="ProjectInstallButtonClicked"
        UninstallButtonClicked="ProjectUninstallButtonClicked"
        Visibility="{Binding Path=IsSolution, Converter={StaticResource InvertedBooleanToVisibilityConverter}}" />

      <!-- solution view when in solution package manager -->
      <nuget:SolutionView
        AutomationProperties.AutomationId="SolutionView"
        x:Name="_solutionView"
        Grid.Row="1"
        Margin="0,8"
        InstallButtonClicked="SolutionInstallButtonClicked"
        UninstallButtonClicked="SolutionUninstallButtonClicked"
        Visibility="{Binding Path=IsSolution,Converter={StaticResource BooleanToVisibilityConverter}}" />

      <!-- the splitter is shown when in solution package manager -->
      <GridSplitter
        Grid.Row="2"
        Height="4"
        HorizontalAlignment="Stretch"
        VerticalAlignment="Top"
        Margin="-24,0,-7,0"
        Visibility="{Binding Path=IsSolution,Converter={StaticResource BooleanToVisibilityConverter}}"
        Background="{DynamicResource {x:Static nuget:Brushes.SplitterBackgroundKey}}"
        BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
        BorderThickness="0,1" />

      <!-- options -->
      <Border
        Grid.Row="3"
        Margin="0,11,0,0"
        BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
        BorderThickness="0,1,0,1">
        <nuget:OptionsControl
          x:Name="_optionsControl"
          Margin="0,12,0,16"
          DataContext="{Binding}" />
      </Border>

      <nuget:PackageMetadataControl
        Grid.Row="4"
        Margin="0,12,0,0"
        DataContext="{Binding PackageMetadata}" />
    </Grid>
  </ScrollViewer>
</UserControl>