<framework:ModalDialogUserControl
  x:Class="NuGet.WebMatrix.NuGetView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:s="clr-namespace:System;assembly=mscorlib"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:self="clr-namespace:NuGet.WebMatrix"
  xmlns:self_data="clr-namespace:NuGet.WebMatrix.Data"
  xmlns:framework="clr-namespace:Microsoft.WebMatrix.Core;assembly=Microsoft.WebMatrix.Core"
  xmlns:excontrols="clr-namespace:Microsoft.WebMatrix.Extensibility.Controls;assembly=Microsoft.WebMatrix.Extensibility"
  xmlns:converters="clr-namespace:Microsoft.WebMatrix.Core.Converters;assembly=Microsoft.WebMatrix.Core"
  xmlns:extensibility="clr-namespace:Microsoft.WebMatrix.Extensibility;assembly=Microsoft.WebMatrix.Extensibility"
  mc:Ignorable="d"
  HorizontalScrollBarVisibility="Disabled"
  VerticalScrollBarVisibility="Disabled"
  x:ClassModifier="internal"
  d:DesignHeight="500"
  d:DesignWidth="600"
  Margin="0"
  Message="{Binding Message}">
  <UserControl.Resources>

    <converters:InverseBoolOrVisibilityToVisibilityCollapsedConverter
      x:Key="inverseVisibilityConverter" />
    <converters:NullToVisibilityConverter
      x:Key="nullToVisibilityConverter" />

    <BooleanToVisibilityConverter
      x:Key="BoolToVis" />
    <self:FixUrlConverter
      x:Key="urlConverter" />
    <self:ColorToBrushConverter
      x:Key="colorToBrushConverter" />

    <DataTemplate
      x:Key="PackageIconTemplate">
      <Grid>
        <framework:PlaceImage
          PlaceholderSource="{x:Static self:PackageViewModel.DefaultIconImageSource}"
          Source="{Binding IconImageSource}"
          Opacity=".8" />
      </Grid>
    </DataTemplate>

    <BitmapImage
      x:Key="BackImage"
      UriSource="..\..\Resources\backarrow.png" />

    <!-- this is the DataTemplate for the 'filter' listview -->
    <DataTemplate
      x:Key="DataTemplate_FilterDefault">
      <StackPanel
        Orientation="Vertical">
        <TextBlock
          Margin="20,7,12,7"
          FontSize="13"
          TextWrapping="Wrap">
            <TextBlock.Text>
              <MultiBinding
              StringFormat="{x:Static self:Resources.MultiFilter_DisplayName}">
                <Binding
                Path="Name" />
                <Binding
                Path="Count" />
              </MultiBinding>
            </TextBlock.Text>
            <TextBlock.ToolTip>
              <ToolTip>
                <TextBlock>
                  <TextBlock.Text>
                    <MultiBinding
                    StringFormat="{x:Static self:Resources.MultiFilter_DisplayName}">
                      <Binding
                      Path="Description" />
                      <Binding
                      Path="Count" />
                    </MultiBinding>
                  </TextBlock.Text>
                </TextBlock>
              </ToolTip>
            </TextBlock.ToolTip>
          </TextBlock>
      </StackPanel>
      <DataTemplate.Triggers>
        <DataTrigger
          Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListViewItem}}"
          Value="True">
          <Setter
            Property="TextElement.FontWeight"
            Value="Bold" />
        </DataTrigger>
      </DataTemplate.Triggers>
    </DataTemplate>
    
    <!-- This is the DataTemplate for loaded items in the main listview -->
    <DataTemplate
      DataType="{x:Type self:PackageViewModel}">
      <Border
        Margin="0,0,12,0"
        SnapsToDevicePixels="true"
        BorderThickness="1">
        <Border.Style>
          <Style>
            <Setter
              Property="Border.BorderBrush"
              Value="Transparent" />
            <Style.Triggers>
              <DataTrigger
                Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}, Path=IsSelected}"
                Value="True">
                <Setter
                  Property="Border.BorderBrush"
                  Value="{DynamicResource {x:Static SystemColors.GradientActiveCaptionBrushKey}}" />
              </DataTrigger>
            </Style.Triggers>
          </Style>
        </Border.Style>

        <Grid
          Height="82">
          <Grid.ColumnDefinitions>
            <ColumnDefinition
              Width="Auto" />
            <ColumnDefinition />
          </Grid.ColumnDefinitions>
          <Grid.InputBindings>
            <MouseBinding
              Gesture="LeftDoubleClick"
              Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type self:NuGetView}}, Path=DataContext.DefaultActionCommand, Mode=OneWay}"
              CommandParameter="True" />
          </Grid.InputBindings>
          <Grid.Style>
            <Style
              TargetType="Grid">
              <!-- This background is for hit-testing, it makes the whole list item clickable -->
              <Setter
                Property="Background"
                Value="Transparent" />
              <Style.Triggers>
                <DataTrigger
                  Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}, Path=IsSelected}"
                  Value="True">
                  <Setter
                    Property="Background"
                    Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                </DataTrigger>
              </Style.Triggers>
            </Style>
          </Grid.Style>
          <Grid
            Column="0">
            <ContentControl
              ContentTemplate="{StaticResource PackageIconTemplate}"
              DataContext="{Binding}"
              Width="50"
              Height="50"
              Margin="5"
              VerticalAlignment="Top"
              Content="{Binding}"
              ToolTip="{Binding Name}" />
          </Grid>
          <Grid
            Column="1"
            VerticalAlignment="Top">
            <Grid.RowDefinitions>
              <RowDefinition
                Height="Auto" />
              <RowDefinition
                Height="Auto" />
              <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock
              x:Name="ItemName"
              Grid.Column="1"
              Grid.Row="0"
              Margin="2 2 2 1"
              FontSize="16"
              FontWeight="Bold"
              Foreground="{DynamicResource {x:Static extensibility:Themes.ClickableTextBrush}}"
              TextTrimming="CharacterEllipsis"
              Text="{Binding Name, Mode=OneWay}">
            </TextBlock>
            <StackPanel
              Orientation="Horizontal"
              Grid.Column="1"
              Grid.Row="1"
              Margin="2 2 2 1">
              <TextBlock
                x:Name="PackageId"
                Margin="0 0 10 0"
                Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"
                Text="{Binding Id, Mode=OneWay}">
                <TextBlock.ToolTip>
                  <ToolTip>
                    <TextBlock
                      Text="{Binding Id, StringFormat={x:Static self:Resources.PackageIdToolTipFormat}}" />
                  </ToolTip>
                </TextBlock.ToolTip>
              </TextBlock>
              <TextBlock
                x:Name="PackageVersion"
                Margin="0 0 10 0"
                Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"
                Text="{Binding DisplayVersion, Mode=OneWay}">
                <TextBlock.Style>
                  <Style
                    TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                      <DataTrigger
                        Binding="{Binding DisplayVersion, Mode=OneWay}"
                        Value="{x:Null}">
                        <Setter
                          Property="Visibility"
                          Value="Collapsed" />
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </TextBlock.Style>
              </TextBlock>
              <TextBlock
                x:Name="DownloadCount"
                Margin="0 0 10 0"
                Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}">
                <TextBlock.Style>
                  <Style
                    TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                      <DataTrigger
                        Binding="{Binding UninstalledDownloadCount}"
                        Value="{x:Null}">
                        <Setter
                          Property="Visibility"
                          Value="Collapsed" />
                      </DataTrigger>
                  </Style.Triggers>
                </Style>
              </TextBlock.Style>
            <Run
                  Text="{x:Static self:Resources.Downloads}" />
            <Run
                  Text="{Binding DownloadCount, Mode=OneWay,StringFormat= \{0:N0\}}" />
              </TextBlock>
              <TextBlock
                x:Name="InstalledVersion"
                Margin="0 0 10 0"
                Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}">
                <TextBlock.Style>
                  <Style
                    TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                      <DataTrigger
                        Binding="{Binding DisplayInstalledVersion, Mode=OneWay}"
                        Value="{x:Null}">
                        <Setter
                          Property="Visibility"
                          Value="Collapsed" />
                      </DataTrigger>
                  </Style.Triggers>
                </Style>
              </TextBlock.Style>
            <Run
                  Text="{x:Static self:Resources.String_InstalledVersion}" />
            <Run
                  Text="{Binding DisplayInstalledVersion, Mode=OneWay}" />
              </TextBlock>                 
            </StackPanel>
            <TextBlock
              x:Name="ItemDescription"
              Grid.Column="1"
              Grid.Row="2"
              Margin="2"
              Foreground="{DynamicResource {x:Static extensibility:Themes.DarkerColorTextBrush}}"
              TextTrimming="CharacterEllipsis"
              TextWrapping="Wrap"
              Text="{Binding Summary, Mode=OneWay}">
            </TextBlock>
          </Grid>
        </Grid>
      </Border>
    </DataTemplate>

    <!-- This is the DataTemplate for 'loading' items in the main listview -->
    <DataTemplate
      DataType="{x:Type self_data:VirtualizingListPlaceholder}">
      <Grid
        Height="80">
        <Grid.ColumnDefinitions>
          <ColumnDefinition
            Width="Auto" />
          <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.Style>
          <Style
            TargetType="Grid">
            <Style.Triggers>
              <DataTrigger
                Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}, Path=IsSelected}"
                Value="True">
                <Setter
                  Property="Background"
                  Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
              </DataTrigger>
            </Style.Triggers>
          </Style>
        </Grid.Style>
        <Grid
          Column="0">
          <Image
            Width="50"
            Height="50"
            Margin="5"
            Source="{x:Static self:PackageViewModel.DefaultIconImageSource}"
            VerticalAlignment="Top"
            ToolTip="Loading..." />
        </Grid>
        <Grid
          Column="1"
          VerticalAlignment="Top">
          <Grid.RowDefinitions>
            <RowDefinition
              Height="Auto" />
            <RowDefinition />
            <RowDefinition
              Height="Auto" />
          </Grid.RowDefinitions>
          <TextBlock
            Grid.Column="1"
            Grid.Row="0"
            Margin="2"
            FontSize="16"
            FontWeight="Bold"
            Foreground="{DynamicResource {x:Static extensibility:Themes.ClickableTextBrush}}"
            TextTrimming="CharacterEllipsis"
            Text="Loading...">
          </TextBlock>
        </Grid>
      </Grid>
    </DataTemplate>

    <!-- This is the style applied to the main list view -->
    <Style
      x:Key="ItemsListViewStyle"
      TargetType="{x:Type ListView}">
      <Setter
        Property="ItemsPanel">
        <Setter.Value>
          <ItemsPanelTemplate>
            <VirtualizingStackPanel />
          </ItemsPanelTemplate>
        </Setter.Value>
      </Setter>
      <Setter
        Property="ScrollViewer.IsDeferredScrollingEnabled"
        Value="True" />
      <Setter
        Property="ItemContainerStyle">
        <Setter.Value>
          <Style
            TargetType="{x:Type ListViewItem}">
            <!-- Makes sure the content fills each row -->
            <Setter
              Property="HorizontalAlignment"
              Value="Stretch" />
            <Setter
              Property="HorizontalContentAlignment"
              Value="Stretch" />
            <!-- Prevents the Border from bleeding through -->
            <Setter
              Property="BorderThickness"
              Value="0" />
            <Setter
              Property="Padding"
              Value="0" />
            <Setter
              Property="Template">
              <Setter.Value>
                <ControlTemplate>
                  <ContentControl
                    Content="{Binding Item}" />
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </Style>
        </Setter.Value>
      </Setter>
      <Setter
        Property="ScrollViewer.HorizontalScrollBarVisibility"
        Value="Disabled" />
    </Style>

    <!-- This is the control template for the 'back' button -->
    <ControlTemplate
      x:Key="ImageButton"
      TargetType="{x:Type Button}">
      <Border>
        <ContentPresenter />
      </Border>
    </ControlTemplate>

    <!-- The Control Template for the Details Pane. Shown when the details pane is activated for the SelectedItem -->
    <!-- The DataContext for the details pan gets set to the Selected Item -->
    <ControlTemplate
      x:Key="ItemDetailsPane">
      <Border
        Margin="0,10,17,0">
        <ScrollViewer
          Margin="2"
          VerticalScrollBarVisibility="Auto"
          HorizontalScrollBarVisibility="Disabled">
          <Grid
            ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <Grid.ColumnDefinitions>
              <ColumnDefinition
                Width="Auto" />
              <ColumnDefinition
                Width="Auto" />
              <ColumnDefinition
                Width="*" />
            </Grid.ColumnDefinitions>

            <!-- The 1st column. Contains the back button-->
            <Button
              Grid.Column="0"
              Template="{StaticResource ImageButton}"
              ToolTip="{x:Static self:Resources.String_Back}"
              VerticalAlignment="Top"
              Margin="10,0,0,0"
              Command="{Binding DataContext.ShowListCommand, RelativeSource={RelativeSource AncestorType={x:Type self:NuGetView}}, Mode=OneWay}"
              AutomationProperties.Name="{x:Static self:Resources.String_Back}"
              AutomationProperties.AutomationId="{x:Static self:Resources.String_Back}">
              <Image
                Source="{StaticResource BackImage}" />
            </Button>

            <!-- The 2nd column. Contains just the icon -->
            <ContentControl
              Grid.Column="1"
              ContentTemplate="{StaticResource PackageIconTemplate}"
              DataContext="{Binding Path=Item}"
              Width="50"
              Height="50"
              Margin="10 0 0 0"
              VerticalAlignment="Top"
              Content="{Binding}"
              ToolTip="{Binding Name}" />

            <!-- The 3rd column. Contains Title, Summary, Download Count, Version and Help Link -->
            <StackPanel
              Grid.Column="2"
              Margin="25,0,0,0">
              <TextBlock
                Text="{Binding Path=Item.Name, Mode=OneWay}"
                TextWrapping="Wrap"
                FontWeight="Bold"
                FontSize="16"
                Margin="0,0,0,20" />
              <TextBlock
                Text="{Binding Path=Item.Description, Mode=OneWay}"
                Foreground="{x:Static SystemColors.WindowTextBrush}"
                TextWrapping="Wrap"
                Margin="0,0,0,20" />

              <!-- This is the table of 'details' -->
              <Grid>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition
                    Width="Auto" />
                  <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                  <RowDefinition />
                  <RowDefinition />
                  <RowDefinition
                    Height="Auto" />
                  <RowDefinition />
                  <RowDefinition />
                  <RowDefinition />
                </Grid.RowDefinitions>

                <!-- Downloads -->
                <TextBlock
                  Grid.Column="0"
                  Grid.Row="0"
                  FontWeight="Bold"
                  Margin="0 0 20 10"
                  Text="{x:Static self:Resources.PackageId}" />
                <TextBlock
                  Grid.Column="1"
                  Grid.Row="0"
                  Text="{Binding Item.Id, Mode=OneWay}" />

                <!-- Downloads -->
                <TextBlock
                  Grid.Column="0"
                  Grid.Row="1"
                  FontWeight="Bold"
                  Margin="0 0 20 10"
                  Text="{x:Static self:Resources.Downloads}" />
                <TextBlock
                  Grid.Column="1"
                  Grid.Row="1"
                  Text="{Binding Item.DownloadCount, Mode=OneWay, StringFormat=\{0:N0\} }" />

                <!-- Authors -->
                <TextBlock
                  Grid.Column="0"
                  Grid.Row="2"
                  FontWeight="Bold"
                  Margin="0 0 20 10"
                  Text="{x:Static self:Resources.String_Authors}" />
                <TextBlock
                  Grid.Column="1"
                  Grid.Row="2"
                  Text="{Binding Item.Authors}"
                  TextWrapping="Wrap" />

                <!-- Last Updated -->
                <TextBlock
                  Grid.Column="0"
                  Grid.Row="3"
                  FontWeight="Bold"
                  Margin="0 0 20 10"
                  Text="{x:Static self:Resources.String_LastUpdated}" />
                <TextBlock
                  Grid.Column="1"
                  Grid.Row="3"
                  Text="{Binding Item.LastUpdated, TargetNullValue={x:Static self:Resources.String_Unknown}}" />

                <!-- Version -->
                <TextBlock
                  Grid.Column="0"
                  Grid.Row="4"
                  FontWeight="Bold"
                  Margin="0 0 20 10"
                  Text="{x:Static self:Resources.String_Version}" />
                <TextBlock
                  Grid.Column="1"
                  Grid.Row="4"
                  Text="{Binding Item.LatestUninstalledVersion, TargetNullValue={x:Static self:Resources.String_Unknown}}" />

                <!-- Installed Version -->
                <TextBlock
                  Grid.Column="0"
                  Grid.Row="5"
                  FontWeight="Bold"
                  Margin="0 0 20 10"
                  Text="{x:Static self:Resources.String_InstalledVersion}" />
                <TextBlock
                  Grid.Column="1"
                  Grid.Row="5"
                  Text="{Binding Item.InstalledVersion, TargetNullValue={x:Static self:Resources.String_NotInstalled}}" />

              </Grid>
              <TextBlock
                Margin="0 0 0 10">
                <TextBlock.Style>
                  <Style
                    TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                      <DataTrigger
                        Binding="{Binding Item.ProjectUrl, Mode=OneWay}"
                        Value="{x:Null}">
                        <Setter
                          Property="Visibility"
                          Value="Collapsed" />
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </TextBlock.Style>
                <Hyperlink
                  Command="{Binding Item.LaunchUrlCommand, Mode=OneWay}"
                  CommandParameter="{Binding Item.ProjectUrl, Mode=OneWay}"
                  Focusable="True">
                  <Run
                    Text="{x:Static self:Resources.String_ViewProjectSite}" />
                </Hyperlink>
              </TextBlock>
              <TextBlock
                Margin="0 0 0 10">
                <TextBlock.Style>
                  <Style
                    TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                      <DataTrigger
                        Binding="{Binding Item.GalleryPackageUrl, Mode=OneWay}"
                        Value="{x:Null}">
                        <Setter
                          Property="Visibility"
                          Value="Collapsed" />
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </TextBlock.Style>
                <Hyperlink
                  Command="{Binding Item.LaunchUrlCommand, Mode=OneWay}"
                  CommandParameter="{Binding Item.GalleryPackageUrl, Mode=OneWay}"
                  Focusable="True">
                  <Run
                    Text="{x:Static self:Resources.String_ViewPackageDetailsOnline}" />
                </Hyperlink>
              </TextBlock>
              <TextBlock
                Margin="0 0 0 10">
                <TextBlock.Style>
                  <Style
                    TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                      <DataTrigger
                        Binding="{Binding Item.ReportAbuseUrl, Mode=OneWay}"
                        Value="{x:Null}">
                        <Setter
                          Property="Visibility"
                          Value="Collapsed" />
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </TextBlock.Style>
                <Hyperlink
                  Command="{Binding Item.LaunchUrlCommand, Mode=OneWay}"
                  CommandParameter="{Binding Item.ReportAbuseUrl, Mode=OneWay}"
                  Focusable="True">
                  <Run
                    Text="{x:Static self:Resources.String_ReportAbuse}" />
                  </Hyperlink>
              </TextBlock>
              
              <!-- Prompt Text -->
              <TextBlock
                Margin="0 20 0 0">
                <TextBlock.Style>
                  <Style
                    TargetType="{x:Type TextBlock}">
                    <Setter
                      Property="Text"
                      Value="{x:Static self:Resources.String_InstallPrompt}" />
                    <Style.Triggers>
                      <DataTrigger
                        Binding="{Binding DataContext.PackageAction, RelativeSource={RelativeSource AncestorType={x:Type self:NuGetView}}}">
                        <DataTrigger.Value>
                          <self:PackageViewModelAction>Update</self:PackageViewModelAction>
                        </DataTrigger.Value>
                        <Setter
                          Property="Text"
                          Value="{x:Static self:Resources.String_UpdatePrompt}" />
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </TextBlock.Style>
              </TextBlock>
            </StackPanel>
          </Grid>
        </ScrollViewer>
      </Border>
    </ControlTemplate>

    <!-- The Control Template for displaying license information about a Package -->
    <!-- The DataContext for this Control Template is a PackgeViewModel instance -->
    <ControlTemplate
      x:Key="LicensePagePackageTemplate">
      <StackPanel
        Orientation="Vertical">
        <TextBlock
          Margin="0,5,0,5"
          FontSize="14">
          <Run
            Text="{Binding Path=Name, Mode=OneWay}" />
          <Run
            Text=" " />
          <Run
            Text="{Binding Path=Version,Mode=OneWay}"
            Foreground="{x:Static SystemColors.GrayTextBrush}" />
        </TextBlock>
        <TextBlock
          Margin="0,0,0,5">
          <TextBlock.Style>
            <Style
              TargetType="{x:Type TextBlock}">
              <Style.Triggers>
                <DataTrigger
                  Binding="{Binding ProjectUrl, Mode=OneWay}"
                  Value="{x:Null}">
                  <Setter
                    Property="Visibility"
                    Value="Collapsed" />
                </DataTrigger>
              </Style.Triggers>
            </Style>
          </TextBlock.Style>
        <Hyperlink
            Command="{Binding LaunchUrlCommand, Mode=OneWay}"
            CommandParameter="{Binding ProjectUrl, Mode=OneWay}"
            Focusable="True">
            <TextBlock
            Text="{x:Static self:Resources.String_ViewProjectSite}" />
        </Hyperlink>
        </TextBlock>
        <TextBlock
          TextWrapping="Wrap"
          Margin="0,0,0,5">
          <TextBlock.Style>
            <Style
              TargetType="{x:Type TextBlock}">
              <Style.Triggers>
                <DataTrigger
                  Binding="{Binding LicenseUrl, Mode=OneWay}"
                  Value="{x:Null}">
                  <Setter
                    Property="Visibility"
                    Value="Collapsed" />
                </DataTrigger>
              </Style.Triggers>
            </Style>
          </TextBlock.Style>
          <Hyperlink
            Command="{Binding LaunchUrlCommand, Mode=OneWay}"
            CommandParameter="{Binding LicenseUrl, Mode=OneWay}"
            Focusable="True">
            <TextBlock
              Text="{x:Static self:Resources.String_ViewLicense}" />
          </Hyperlink>
        </TextBlock>
      </StackPanel>
    </ControlTemplate>

        <SolidColorBrush x:Shared="False"
                         x:Key="ListViewWithPointerStroke"
                         Color="#FFDDDDDD" />

        <LinearGradientBrush x:Shared="false"
                             x:Key="ListViewWithPointerGradient"
                             StartPoint="0,1"
                             EndPoint="0,0">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="#FFFFFFFF"
                              Offset="0" />

                <GradientStop Color="#FFEEEEEE"
                              Offset="0.0642284" />

                <GradientStop Color="#FFDDDDDD"
                              Offset="0.135593" />

                <GradientStop Color="#FFDDDDDD"
                              Offset="0.923729" />

                <GradientStop Color="#FFFFFFFF"
                              Offset="1" />
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <!-- this is the style for the 'filter' listview  -->
        <Style TargetType="{x:Type self:ListViewWithPointer}">
            <Setter Property="Background"
                    Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />

            <Setter Property="BorderThickness"
                    Value="1" />

            <Setter Property="Foreground"
                    Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />

            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
                    Value="Auto" />

            <Setter Property="ScrollViewer.VerticalScrollBarVisibility"
                    Value="Auto" />

            <Setter Property="ScrollViewer.CanContentScroll"
                    Value="true" />

            <Setter Property="VerticalContentAlignment"
                    Value="Center" />

            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type self:ListViewWithPointer}">
                        <Grid>
                            <Border x:Name="Bd"
                                    SnapsToDevicePixels="true"
                                    Background="{TemplateBinding Background}"
                                    Padding="0">
                                <ScrollViewer Padding="{TemplateBinding Padding}"
                                              Focusable="false">
                                    <ItemsPresenter x:Name="ItemsPresenter" />
                                </ScrollViewer>
                            </Border>

                            <Rectangle Stroke="{x:Null}"
                                       Margin="0,0,0,0"
                                       VerticalAlignment="Stretch"
                                       Width="1"
                                       HorizontalAlignment="Right"
                                       Fill="{StaticResource ListViewWithPointerGradient}" />

                            <Grid x:Name="Pointer"
                                  HorizontalAlignment="Right"
                                  VerticalAlignment="Top"
                                  Width="18.5"
                                  Height="30">

                                <!-- All three of these shapes are in fact needed, including both 'copies' of the pointer -->
                                <Path Fill="{DynamicResource {x:Static extensibility:Themes.ApplicationBackgroundBrush}}"
                                      Stretch="Fill"
                                      Stroke="{StaticResource ListViewWithPointerStroke}"
                                      StrokeEndLineCap="Flat"
                                      StrokeLineJoin="Miter"
                                      StrokeMiterLimit="10"
                                      StrokeStartLineCap="Flat"
                                      StrokeThickness="1"
                                      Data="M12,14.833333 L29.5,0.5 29.5,29.5 12,14.833333 z"
                                      Margin="6,1,-0.307,-1" />

                                <Path Fill="{DynamicResource {x:Static extensibility:Themes.ApplicationBackgroundBrush}}"
                                      Stretch="Fill"
                                      Stroke="{StaticResource ListViewWithPointerStroke}"
                                      StrokeEndLineCap="Flat"
                                      StrokeLineJoin="Miter"
                                      StrokeMiterLimit="10"
                                      StrokeStartLineCap="Flat"
                                      StrokeThickness="1"
                                      Data="M12,14.833333 L29.5,0.5 29.5,29.5 12,14.833333 z"
                                      Margin="6,0,-0.307,0" />

                                <Path Fill="{DynamicResource {x:Static extensibility:Themes.ApplicationBackgroundBrush}}"
                                      Stretch="Fill"
                                      StrokeEndLineCap="Flat"
                                      StrokeLineJoin="Miter"
                                      StrokeMiterLimit="10"
                                      StrokeStartLineCap="Flat"
                                      StrokeThickness="1"
                                      Data="M12,14.888889 L29.5,0.5 29.5,29.5 12,14.888889 z"
                                      Margin="7.331,0,-1,0" />
                            </Grid>
                        </Grid>

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled"
                                     Value="false">
                                <Setter Property="Background"
                                        TargetName="Bd"
                                        Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                            </Trigger>

                            <Trigger Property="IsGrouping"
                                     Value="true">
                                <Setter Property="ScrollViewer.CanContentScroll"
                                        Value="false" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


    </UserControl.Resources>

  <!-- 
    The main content area of the gallery has a few panels stacked on top of each other
     * The 'loading' spinner
     * The 'main' gallery list
     * The various 'wizard' pages
    
    At any point, only one of these panels at a time should be shown, and the rest collapsed.
  -->
  <Grid
    Margin="0">

    <!-- The 'loading spinner'  - only show the stackpanel if Loading, or IsSearching -->
    <StackPanel
      Orientation="Horizontal"
      VerticalAlignment="Center"
      HorizontalAlignment="Center"
      Margin="20">
      <StackPanel.Style>
        <Style
          TargetType="{x:Type StackPanel}">
          <Setter
            Property="Visibility"
            Value="Collapsed" />
          <Style.Triggers>
            <DataTrigger
              Binding="{Binding Loading}"
              Value="true">
              <Setter
                Property="Visibility"
                Value="Visible" />
            </DataTrigger>
            <DataTrigger
              Binding="{Binding IsSearching}"
              Value="true">
              <Setter
                Property="Visibility"
                Value="Visible" />
            </DataTrigger>
          </Style.Triggers>
        </Style>
      </StackPanel.Style>

      <excontrols:SpinnerControl
        Width="24"
        Height="24"
        Margin="0,0,8,0" 
        x:Name="SpinnerControl"/>

      <TextBlock
        VerticalAlignment="Center">
        <TextBlock.Style>
          <Style
            TargetType="{x:Type TextBlock}">
          <Style.Triggers>
            <DataTrigger
                Binding="{Binding Loading}"
                Value="true">
              <Setter
                  Property="Text"
                  Value="{Binding Path=LoadingMessage, Mode=OneWay}" />
            </DataTrigger>
            <DataTrigger
                Binding="{Binding IsSearching}"
                Value="true">
              <Setter
                  Property="Text"
                  Value="{Binding Path=SearchingMessage, Mode=OneWay}" />
            </DataTrigger>
          </Style.Triggers>
            </Style>
        </TextBlock.Style>
      </TextBlock>
    </StackPanel>

    <!-- The 'main' gallery content -  shown when one of the other pages is not -->
    <Grid
      x:Name="Grid"
      Margin="0">
      <Grid.Style>
        <Style
          TargetType="{x:Type Grid}">
          <Style.Triggers>
            <DataTrigger
              Binding="{Binding Path=IsLicensePageVisible, Mode=OneWay}"
              Value="True">
              <Setter
                Property="Visibility"
                Value="Collapsed" />
            </DataTrigger>
            <DataTrigger
              Binding="{Binding Path=IsUninstallPageVisible, Mode=OneWay}"
              Value="True">
              <Setter
                Property="Visibility"
                Value="Collapsed" />
            </DataTrigger>
            <DataTrigger
              Binding="{Binding Path=Loading, Mode=OneWay}"
              Value="True">
              <Setter
                Property="Visibility"
                Value="Collapsed" />
            </DataTrigger>
            <DataTrigger
              Binding="{Binding Path=IsSearching, Mode=OneWay}"
              Value="True">
              <Setter
                Property="Visibility"
                Value="Collapsed" />
            </DataTrigger>
          </Style.Triggers>
        </Style>
      </Grid.Style>

        <Grid.ColumnDefinitions>
          <ColumnDefinition
            Width="2*" />
          <ColumnDefinition
            Width="8*" />
        </Grid.ColumnDefinitions>

        <self:ListViewWithPointer
          Grid.Column="0"
          AutomationProperties.AutomationId="FilterListView"
          IsTextSearchEnabled="True"
          TextSearch.TextPath="Name"
          ItemsSource="{Binding Filters, Mode=OneWay}"
          HorizontalContentAlignment="Stretch"
          BorderBrush="Transparent"
          Focusable="False"
          ItemTemplate="{StaticResource DataTemplate_FilterDefault}"
          SelectedItem="{Binding SelectedFilter, Mode=TwoWay}"
          IsTabStop="True"
          TabIndex="0"
          ScrollViewer.HorizontalScrollBarVisibility="Disabled">
        </self:ListViewWithPointer>

        <Grid
          Grid.Column="1"
          Margin="10,0,0,0">

          <Grid.RowDefinitions>
            <RowDefinition
              Height="Auto" />

            <RowDefinition
              Height="*" />

          </Grid.RowDefinitions>

          <TextBlock
            Grid.Row="0"
            x:Name="_noResultsTextBlock"
            HorizontalAlignment="Center"
            Margin="0,40,0,0">
            <TextBlock.Style>
              <Style
                TargetType="{x:Type TextBlock}">
                <Setter
                  Property="Text"
                  Value="{x:Static self:Resources.String_YourQueryReturnedZeroResults}" />
                <Setter
                  Property="Focusable"
                  Value="True" />
                <Setter
                  Property="Visibility"
                  Value="Collapsed" />
                <Style.Triggers>
                  <DataTrigger
                    Binding="{Binding HasItems, ElementName=_itemsListView}"
                    Value="False">
                    <Setter
                      Property="Visibility"
                      Value="Visible" />
                  </DataTrigger>
                </Style.Triggers>
              </Style>
            </TextBlock.Style>
          </TextBlock>

          <ListView
            Grid.Row="1"
            Name="_itemsListView"
            BorderBrush="{x:Null}"
            ItemsSource="{Binding SelectedFilter.FilteredItems}"
            Focusable="False"
            IsTextSearchEnabled="True"
            TextSearch.TextPath="Name"
            Style="{StaticResource ItemsListViewStyle}"
            SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
            ScrollViewer.VerticalScrollBarVisibility="Visible"
            IsTabStop="True"
            TabIndex="1"
            Visibility="{Binding IsDetailsPaneVisible, Mode=OneWay, Converter={StaticResource inverseVisibilityConverter}}">
            <ListView.InputBindings>
              <KeyBinding
                Key="Space"
                Command="{Binding DefaultActionCommand}" />
              <KeyBinding
                Key="Enter"
                Command="{Binding DefaultActionCommand}" />
            </ListView.InputBindings>
          </ListView>

          <!-- This is the Details Pane control -->
          <Control
            Grid.Row="1"
            Name="_detailsPaneControl"
            Template="{StaticResource ItemDetailsPane}"
            DataContext="{Binding SelectedItem}"
            Visibility="{Binding DataContext.IsDetailsPaneVisible, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type self:NuGetView}}, Converter={StaticResource BoolToVis}}" />
          
        </Grid>
    </Grid>

    <!-- This is the grid which is displayed to show the install details, Eula, etc. -->
    <Grid
      x:Name="InstallPageGrid"
      Margin="20"
      Visibility="{Binding Path=IsLicensePageVisible, Converter={StaticResource BoolToVis}, Mode=OneWay}">

      <!--Inner Grid so we can set the DataContext -->
      <Grid
        DataContext="{Binding Path=SelectedItem}">
        <Grid.ColumnDefinitions>
          <ColumnDefinition
            Width="Auto" />
          <ColumnDefinition
            Width="*" />
        </Grid.ColumnDefinitions>

        <!-- 1st column. This is the image for the package -->
        <ContentControl
          Grid.Column="0"
          ContentTemplate="{StaticResource PackageIconTemplate}"
          DataContext="{Binding Path=Item}"
          VerticalAlignment="Top"
          Width="50"
          Height="50"
          Opacity=".8"
          Margin="5"
          Content="{Binding}"
          ToolTip="{Binding Name}" />

        <!-- 2nd column. Contains all the text and information -->
        <ScrollViewer
          Grid.Column="1"
          VerticalScrollBarVisibility="Auto">

          <!-- 
            This style forces the scrollbar to consume space 'outside' the normal bounds of the content.
            The scrollbar is right aligned to the edge of the dialog, but the content area remains the same
            whether or not it's hidden.
          -->
          <ScrollViewer.Style>
            <Style
              TargetType="{x:Type ScrollViewer}">
              <Setter
                Property="Margin"
                Value="20 0 0 0" />
              <Style.Triggers>
                <Trigger
                  Property="ComputedVerticalScrollBarVisibility"
                  Value="Visible">
                  <Setter
                    Property="Margin"
                    Value="20 0 -20 0" />
                </Trigger>
              </Style.Triggers>
            </Style>
          </ScrollViewer.Style>
          <Grid>
            <Grid.RowDefinitions>
              <RowDefinition
                Height="*" />
              <RowDefinition
                Height="Auto" />
            </Grid.RowDefinitions>
            <StackPanel
              Grid.Row="0">
              <TextBlock
                Text="{x:Static self:Resources.String_AcceptEula}"
                FontSize="16"
                FontWeight="Bold" />
              <TextBlock
                Text="{x:Static self:Resources.String_HeaderText}"
                TextWrapping="Wrap"
                Margin="0,10,0,0" />
              <StackPanel x:Name="UpdateAllEula"
                    Orientation="Vertical"
                    Margin="0,10,0,0">
                    <StackPanel.Style>
                      <Style
                        TargetType="{x:Type StackPanel}">
                        <Style.Triggers>
                          <DataTrigger
                            Binding="{Binding ElementName=InstallPageGrid, Path=IsVisible, Mode=OneWay}"
                            Value="True">
                            <Setter
                              Property="Visibility"
                              Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type self:NuGetView}}, Path=DataContext.IsUpdatingAll, 
                                Converter={StaticResource BoolToVis}, Mode=OneWay}" />
                          </DataTrigger>
                        </Style.Triggers>
                      </Style>
                    </StackPanel.Style>
                    <TextBlock
                      Text="{x:Static self:Resources.String_PackagesForUpdateAll}" />
                    <ItemsControl
                      x:Name="UpdateAllPackages">
                      <ItemsControl.Style>
                        <Style
                          TargetType="{x:Type ItemsControl}">
                          <Style.Triggers>
                            <DataTrigger
                              Binding="{Binding ElementName=InstallPageGrid, Path=IsVisible, Mode=OneWay}"
                              Value="True">
                              <Setter
                                Property="ItemsSource"
                                Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type self:NuGetView}}, Path=DataContext.PackagesToDisplayForUpdateAll}" />
                            </DataTrigger>
                          </Style.Triggers>
                        </Style>
                      </ItemsControl.Style>
                      <ItemsControl.ItemTemplate>
                        <DataTemplate>
                          <Control
                            Template="{StaticResource LicensePagePackageTemplate}"
                            Margin="0,5,0,0" />
                        </DataTemplate>
                      </ItemsControl.ItemTemplate>
                      <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                          <StackPanel
                            Orientation="Vertical" />
                        </ItemsPanelTemplate>
                      </ItemsControl.ItemsPanel>
                    </ItemsControl>                  
              </StackPanel>
              <StackPanel
                    Orientation="Vertical"
                    Margin="0,10,0,0">
                    <StackPanel.Style>
                      <Style
                        TargetType="{x:Type StackPanel}">
                        <Style.Triggers>
                          <DataTrigger
                            Binding="{Binding ElementName=InstallPageGrid, Path=IsVisible, Mode=OneWay}"
                            Value="True">
                            <Setter
                              Property="Visibility"
                              Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type self:NuGetView}}, Path=DataContext.NotUpdatingAll, 
                                Converter={StaticResource BoolToVis}, Mode=OneWay}" />
                          </DataTrigger>
                        </Style.Triggers>
                      </Style>
                    </StackPanel.Style>
                  <Control
                    Template="{StaticResource LicensePagePackageTemplate}"
                    Margin="0,20,0,0"
                    DataContext="{Binding Path=Item}" />
                  <StackPanel
                    Orientation="Vertical"
                    Margin="0,10,0,0">
                    <StackPanel.Style>
                      <Style
                        TargetType="{x:Type StackPanel}">
                        <Style.Triggers>
                          <DataTrigger
                            Binding="{Binding ElementName=InstallPageGrid, Path=IsVisible, Mode=OneWay}"
                            Value="True">
                            <Setter
                              Property="Visibility"
                              Value="{Binding Path=Item.Dependencies, Converter={StaticResource nullToVisibilityConverter}, Mode=OneWay}" />
                          </DataTrigger>
                        </Style.Triggers>
                      </Style>
                    </StackPanel.Style>
                    <TextBlock
                      Text="{x:Static self:Resources.String_DependenciesToBeInstall}" />
                    <ItemsControl
                      x:Name="Dependencies">
                      <ItemsControl.Style>
                        <Style
                          TargetType="{x:Type ItemsControl}">
                          <Style.Triggers>
                            <DataTrigger
                              Binding="{Binding ElementName=InstallPageGrid, Path=IsVisible, Mode=OneWay}"
                              Value="True">
                              <Setter
                                Property="ItemsSource"
                                Value="{Binding Path=Item.Dependencies}" />
                            </DataTrigger>
                          </Style.Triggers>
                        </Style>
                      </ItemsControl.Style>
                      <ItemsControl.ItemTemplate>
                        <DataTemplate>
                          <Control
                            Template="{StaticResource LicensePagePackageTemplate}"
                            Margin="0,5,0,0" />
                        </DataTemplate>
                      </ItemsControl.ItemTemplate>
                      <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                          <StackPanel
                            Orientation="Vertical" />
                        </ItemsPanelTemplate>
                      </ItemsControl.ItemsPanel>
                    </ItemsControl>
                  </StackPanel>
                </StackPanel>
            </StackPanel>
            <TextBlock
              Grid.Row="1"
              Text="{x:Static self:Resources.String_LicenseText}"
              TextWrapping="Wrap"
              Foreground="{x:Static SystemColors.GrayTextBrush}" />
          </Grid>
        </ScrollViewer>
      </Grid>
    </Grid>

    <!-- This is the grid which is displayed to confirm you want to uninstall -->
    <Grid
      x:Name="UninstallPageGrid"
      Margin="20"
      Visibility="{Binding Path=IsUninstallPageVisible, Converter={StaticResource BoolToVis}, Mode=OneWay}">

      <!--Inner Grid so we can set the DataContext -->
      <Grid
        DataContext="{Binding Path=SelectedItem}">
        <Grid.ColumnDefinitions>
          <ColumnDefinition
            Width="Auto" />
          <ColumnDefinition
            Width="*" />
        </Grid.ColumnDefinitions>

        <!-- 1st column. This is the image for the package -->
        <ContentControl
          ContentTemplate="{StaticResource PackageIconTemplate}"
          DataContext="{Binding Path=Item}"
          VerticalAlignment="Top"
          Width="50"
          Height="50"
          Margin="5"
          Opacity=".8"
          Content="{Binding}"
          ToolTip="{Binding Name}" />

        <!-- 2nd column. Contains all the text and information -->
        <Grid
          Grid.Column="1"
          Margin="20,0,0,0">
          <StackPanel
            Orientation="Vertical">
            <TextBlock
              FontSize="16"
              FontWeight="Bold"
              TextWrapping="Wrap">
              <Run
                Text="{x:Static self:Resources.String_Uninstall}" />
              <Run
                Text="{Binding Path=Item.Name, StringFormat= \{0\}, Mode=OneWay}" />
            </TextBlock>
            <TextBlock
              Text="{x:Static self:Resources.String_UninstallMessage}"
              TextWrapping="Wrap"
              FontSize="14" />
          </StackPanel>
        </Grid>
      </Grid>
    </Grid>
  </Grid>
</framework:ModalDialogUserControl>
