<?xml version="1.0" encoding="utf-8"?>
<xdb:ExplorerContent
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:model="clr-namespace:Microsoft.Data.Entity.Design.UI.ViewModels.Explorer"
  xmlns:conv="clr-namespace:Microsoft.Data.Entity.Design.UI.Converters;assembly=Microsoft.Data.Tools.Design.XmlCore"
  xmlns:s="clr-namespace:System;assembly=mscorlib"
  xmlns:xdb="clr-namespace:Microsoft.Data.Entity.Design.UI.Views.Explorer;assembly=Microsoft.Data.Tools.Design.XmlCore"
  xmlns:coreCtrls="clr-namespace:Microsoft.Data.Entity.Design.Core.Controls;assembly=Microsoft.Data.Tools.Design.XmlCore"
  xmlns:vsShell11="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0"
  xmlns:Design="clr-namespace:Microsoft.Data.Entity.Design"
  SnapsToDevicePixels="True"
  UseLayoutRounding="True"
  TextOptions.TextFormattingMode="Display"
  Background="{DynamicResource VsBrush.ToolWindowBackground}"
  x:Class="Microsoft.Data.Entity.Design.UI.Views.Explorer.EntityDesignExplorerContent"
  KeyboardNavigation.TabNavigation="Cycle"
  KeyboardNavigation.ControlTabNavigation="None"
  >

  <Grid.Resources>
    <ResourceDictionary>

      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Microsoft.Data.Entity.Design;Component/Resources/EscherIcons.xaml" />
      </ResourceDictionary.MergedDictionaries>

      <s:Boolean x:Key="BooleanFalseValue">False</s:Boolean>
      <s:Boolean x:Key="BooleanTrueValue">True</s:Boolean>

      <!-- Converters ********************************************** -->
      <conv:IndentToMarginConverter x:Key="IndentToMarginConverter"/>

      <conv:SwitchConverter x:Key="NegateConverter" DefaultValue="{StaticResource BooleanFalseValue}">
        <conv:SwitchCase In="{StaticResource BooleanFalseValue}" Out="{StaticResource BooleanTrueValue}"/>
        <conv:SwitchCase In="{StaticResource BooleanTrueValue}" Out="{StaticResource BooleanFalseValue}"/>
      </conv:SwitchConverter>

      <conv:SwitchConverter x:Key="BoolToHiddenConverter" DefaultValue="{x:Static Visibility.Hidden}">
        <conv:SwitchCase In="{StaticResource BooleanFalseValue}" Out="{x:Static Visibility.Visible}"/>
        <conv:SwitchCase In="{StaticResource BooleanTrueValue}" Out="{x:Static Visibility.Hidden}"/>
      </conv:SwitchConverter>

      <!-- Selector for Hierarchical Data Templates -->
      <xdb:ExplorerTemplateSelector x:Key="ExplorerSelector" />

      <vsShell11:ThemedImageSourceConverter x:Key="ThemedImageSourceConverter" />
      <vsShell11:BrushToColorConverter x:Key="BrushToColorConverter" />

      <!--**********************************************************-->
      <!--Styles ***************************************************-->

      <!-- Search Previous Nav Path Style **************************-->
      <Style        x:Key=      "ExplorerSearchPrevNavPathStyle"
                    TargetType= "{x:Type Path}" >
        <Style.Triggers>
          <DataTrigger  Binding="{Binding CanGotoPreviousResult}"
                        Value="False">
            <Setter     Property="Opacity"
                        Value="0.3" />
          </DataTrigger>
        </Style.Triggers>
      </Style>

      <!-- Search Next Nav Path Style ******************************-->
      <Style        x:Key=      "ExplorerSearchNextNavPathStyle"
                    TargetType= "{x:Type Path}" >
        <Style.Triggers>
          <DataTrigger  Binding="{Binding CanGotoNextResult}"
                        Value="False">
            <Setter     Property="Opacity"
                        Value="0.3" />
          </DataTrigger>
        </Style.Triggers>
      </Style>

      <!-- ToolBarButton Style  ************************************-->
      <Style      x:Key=      "ToolBarButtonStyle"
                  BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                  TargetType="{x:Type Button}">
        <Setter   Property="FocusVisualStyle"
                  Value="{x:Null}" />
      </Style>

      <!-- IsAncestorOfSearchResultItemStyle TextBlock Style ************************ -->
      <Style x:Key="IsAncestorOfSearchResultItemStyle"
          TargetType="{x:Type ContentControl}">
        <Setter Property="Visibility" Value="Collapsed" />
        <EventSetter Event="MouseDown" Handler="OnMouseDownAncestorOfSearchResultItemStyle"/>
        <Style.Triggers>
          <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
              <Condition Binding="{Binding Path=IsAncestorOfSearchResultItem }" Value="True" />
              <Condition Binding="{Binding Path=IsExpanded }" Value="False" />
            </MultiDataTrigger.Conditions>
            <MultiDataTrigger.Setters>
              <Setter Property="Template">
                <Setter.Value>
                  <ControlTemplate TargetType="{x:Type ContentControl}">
                    <StackPanel Orientation="Horizontal"
                                Background="{DynamicResource {x:Static vsShell11:TreeViewColors.HighlightedSpanBrushKey}}">
                      <Image Source="{StaticResource SearchIcon}" Width="16" Height="16" />
                      <TextBlock Text="..."
                                 Margin="-2,0,2,0"
                                 VerticalAlignment="Center"
                                 Foreground="{DynamicResource {x:Static vsShell11:TreeViewColors.HighlightedSpanTextBrushKey}}"/>
                    </StackPanel>
                  </ControlTemplate>
                </Setter.Value>
              </Setter>
              <Setter Property="ToolTip" Value="{x:Static Design:Resources.ExplorerContent_CollapseSearchResults}"/>
              <Setter Property="Focusable"  Value="False" />
              <Setter Property="Visibility" Value="Visible" />
            </MultiDataTrigger.Setters>
          </MultiDataTrigger>
        </Style.Triggers>
      </Style>

      <!-- SearchBar Style *****************************************-->
      <Style x:Key="SearchBarStyle" TargetType="{x:Type Border}">
        <Style.Triggers>
          <Trigger Property="Visibility" Value="Visible">
            <Trigger.EnterActions>
              <BeginStoryboard>
                <Storyboard>
                  <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                   From="0"
                                   To="1"
                                   Duration="0:0:1" />
                </Storyboard>
              </BeginStoryboard>
            </Trigger.EnterActions>
          </Trigger>
        </Style.Triggers>
      </Style>

      <!--Image Style **********************************************-->
      <Style        x:Key=      "DrImage"
                    TargetType= "{x:Type Image}" >
        <Setter     Property=   "Margin"
                    Value=      "2,0,2,0" />
        <Setter     Property=   "Width"
                    Value=      "16" />
        <Setter     Property=   "Height"
                    Value=      "16" />
      </Style>

      <!-- OverlayRefStyle Style ***********************************-->
      <Style        x:Key=      "OverlayRefStyle"
                    TargetType= "{x:Type ContentControl}" >
        <Setter     Property=   "Width"
                    Value=      "16" />
        <Setter     Property=   "Height"
                    Value=      "16" />
        <Setter     Property="Focusable"
                    Value=      "False"/>
        <Setter     Property=   "Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type ContentControl}">
              <ContentPresenter Margin="{TemplateBinding Padding}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
        <Style.Triggers>
          <DataTrigger Binding="{Binding Path=IsReference}" Value="True">
            <Setter    Property="Template">
              <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContentControl}">
                  <Grid>
                    <ContentPresenter Margin="{TemplateBinding Padding}"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    <Image Source="{StaticResource RefIcon}" Style="{StaticResource DrImage}"/>
                  </Grid>
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </DataTrigger>
        </Style.Triggers>
      </Style>

      <!-- TreeView Item Style ************************************* -->
      <Style TargetType="{x:Type xdb:ExplorerTreeViewItem}">
        <Setter     Property=   "IsExpanded"
                    Value=      "{Binding Path=IsExpanded, Mode=TwoWay}" />
        <Setter     Property=   "IsSelected"
                    Value=      "{Binding Path=IsSelected, Mode=TwoWay}" />
        <Setter     Property=   "coreCtrls:EditableContentControl.IsInEditMode"
                    Value=      "{Binding Path=IsInEditMode, Mode=TwoWay}" />
        <Setter     Property=   "coreCtrls:EditableContentControl.IsEditModeAllowed"
                    Value=      "{Binding Path=IsEditableInline, Mode=OneWay}" />
        <Setter     Property=   "Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type xdb:ExplorerTreeViewItem}">
              <Grid>
                <Grid.RowDefinitions>
                  <RowDefinition Height="Auto"/>
                  <RowDefinition/>
                </Grid.RowDefinitions>
                <!-- When a TreeViewItem is selected, the ScrollViewer scrolls
                to reveal the top,left of PART_Header.  Keeping PART_Header
                spanning the entire TreeView width keeps the ScrollViewer from
                scrolling. -->
                <!-- TODO: is it ok to remove the PART_Header name entirely?  -->
                <Border x:Name="PART_Header"
                  Background="Transparent"
                  Padding="{Binding Indent, Converter={StaticResource IndentToMarginConverter}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type xdb:ExplorerTreeViewItem}}, Mode=OneTime}"
                  SnapsToDevicePixels="true">
                  <StackPanel Orientation="Horizontal">
                    <ToggleButton x:Name="Expander" ClickMode="Press" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}">
                      <ToggleButton.Style>
                        <Style TargetType="{x:Type ToggleButton}">
                          <Setter Property="Focusable" Value="False"/>
                          <Setter Property="Width" Value="16"/>
                          <Setter Property="Height" Value="16"/>
                          <Setter Property="Template">
                            <Setter.Value>
                              <ControlTemplate TargetType="{x:Type ToggleButton}">
                                <Border Background="Transparent" Height="16" Padding="0" Width="16" SnapsToDevicePixels="True" >
                                  <Path x:Name="ExpandPath" Data="M 0 0 L 4 4 L 0 8 Z"
                                        Stroke="{DynamicResource {x:Static vsShell11:TreeViewColors.GlyphBrushKey}}"
                                        SnapsToDevicePixels="False" >
                                    <!-- Expander triangles needs half-pixel possitioning to render correctly -->
                                    <Path.RenderTransform>
                                      <TranslateTransform  X="6.5" Y="4.5"/>
                                    </Path.RenderTransform>
                                  </Path>
                                </Border>
                                <ControlTemplate.Triggers>
                                  <!-- Rotate and fill triangle when checked (i.e. item is expanded) -->
                                  <Trigger Property="IsChecked" Value="True">
                                    <Setter Property="Data" TargetName="ExpandPath" Value="M 5 2 L 0 7 L 5 7 Z" />
                                    <Setter Property="Fill" TargetName="ExpandPath" Value="{DynamicResource {x:Static vsShell11:TreeViewColors.GlyphBrushKey}}"/>
                                  </Trigger>
                                  <!-- Update stroke and fill color as necessary on mouse over -->
                                  <Trigger Property ="IsMouseOver" Value="True">
                                    <Setter Property="Stroke" TargetName="ExpandPath" Value="{DynamicResource {x:Static vsShell11:TreeViewColors.GlyphMouseOverBrushKey}}"/>
                                  </Trigger>
                                  <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                      <Condition Property="IsChecked" Value="True"/>
                                      <Condition Property="IsMouseOver" Value="True"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Fill" TargetName="ExpandPath" Value="{DynamicResource {x:Static vsShell11:TreeViewColors.GlyphMouseOverBrushKey}}"/>
                                  </MultiTrigger>
                                </ControlTemplate.Triggers>
                              </ControlTemplate>
                            </Setter.Value>
                          </Setter>
                        </Style>
                      </ToggleButton.Style>
                    </ToggleButton>
                    <!-- Add space between expander and item icon -->
                    <Border Background="Transparent" Width="7" Height="16" />
                    <Image x:Name ="ExplorerTreeViewItemIcon" Style="{StaticResource DrImage}">
                      <Image.Source>
                        <MultiBinding Converter="{StaticResource ThemedImageSourceConverter}">
                          <Binding Path="Icon" Mode="OneWay" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type xdb:ExplorerTreeViewItem}}" />
                          <Binding Path="(vsShell11:ImageThemingUtilities.ImageBackgroundColor)" RelativeSource="{RelativeSource Self}" />
                          <Binding Source="{x:Static vsShell11:Boxes.BooleanTrue}"/>
                        </MultiBinding>
                      </Image.Source>
                    </Image>
                    <Border x:Name="Bd"
                      Background="{TemplateBinding Background}"
                      BorderBrush="{TemplateBinding BorderBrush}"
                      BorderThickness="{TemplateBinding BorderThickness}"
                      Padding="2,2,3,1"
                      SnapsToDevicePixels="true">
                      <ContentPresenter
                        ContentSource="Header"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                  </StackPanel>
                </Border>
                <ItemsPresenter x:Name="ItemsHost" Grid.Row="1" />
              </Grid>
              <ControlTemplate.Triggers>
                <Trigger Property="IsExpanded" Value="false">
                  <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
                </Trigger>
                <Trigger Property="HasItems" Value="false">
                  <Setter TargetName="Expander" Property="Visibility" Value="Hidden"/>
                </Trigger>
                <!-- Ensure foreground for non-search results has foreground brush which reacts to theme changes -->
                <DataTrigger  Binding= "{Binding Path=IsInSearchResults}" Value="False">
                  <Setter Property="Foreground" Value="{DynamicResource {x:Static vsShell11:TreeViewColors.BackgroundTextBrushKey}}" />
                </DataTrigger>
                <MultiTrigger>
                  <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="true" />
                    <Condition Property="coreCtrls:EditableContentControl.IsInEditMode" Value="false"/>
                    <Condition Property="IsSelectionActive" Value="true"/>
                  </MultiTrigger.Conditions>
                  <Setter TargetName="Bd" Property="Background"
                    Value="{DynamicResource {x:Static vsShell11:TreeViewColors.SelectedItemActiveBrushKey}}"/>
                  <Setter Property="Foreground"
                    Value="{DynamicResource {x:Static vsShell11:TreeViewColors.SelectedItemActiveTextBrushKey}}"/>
                </MultiTrigger>
                <MultiTrigger>
                  <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="true"/>
                    <Condition Property="coreCtrls:EditableContentControl.IsInEditMode" Value="false"/>
                    <Condition Property="IsSelectionActive" Value="false"/>
                  </MultiTrigger.Conditions>
                  <Setter TargetName="Bd" Property="Background"
                    Value="{DynamicResource {x:Static vsShell11:TreeViewColors.SelectedItemInactiveBrushKey}}"/>
                  <Setter Property="Foreground"
                    Value="{DynamicResource {x:Static vsShell11:TreeViewColors.SelectedItemInactiveTextBrushKey}}"/>
                </MultiTrigger>
                <Trigger Property="IsEnabled" Value="false">
                  <Setter Property="Foreground"
                    Value="{DynamicResource VsBrush.GrayText}"/>
                </Trigger>
                <MultiDataTrigger>
                  <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=IsAncestorOfSearchResultItem }" Value="True" />
                    <Condition Binding="{Binding Path=IsExpanded }" Value="False" />
                  </MultiDataTrigger.Conditions>
                  <!-- Note: colors for both background and foreground which show up well in both light and dark themes -->
                  <Setter Property="Background" Value="{DynamicResource {x:Static vsShell11:TreeViewColors.HighlightedSpanBrushKey}}" />
                  <Setter Property="Foreground" Value="{DynamicResource {x:Static vsShell11:TreeViewColors.HighlightedSpanTextBrushKey}}" />
                </MultiDataTrigger>

                <MultiDataTrigger>
                  <MultiDataTrigger.Conditions>
                    <Condition Binding= "{Binding Path=IsInSearchResults}" Value="True" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}" Value="False" />
                  </MultiDataTrigger.Conditions>
                  <!-- Note: colors for both background and foreground which show up well in both light and dark themes -->
                  <Setter Property="Background" Value="{DynamicResource {x:Static vsShell11:TreeViewColors.HighlightedSpanBrushKey}}" />
                  <Setter Property="Foreground" Value="{DynamicResource {x:Static vsShell11:TreeViewColors.HighlightedSpanTextBrushKey}}" />
                  <Setter Property="Selector.IsSelected" TargetName="Bd" Value="{DynamicResource {x:Static SystemParameters.HighContrastKey}}" />
                </MultiDataTrigger>

                <!-- Also ensure that non-expanded, selected ancestors of a search result have the normal foreground brush which reacts to theme changes -->
                <MultiDataTrigger>
                  <MultiDataTrigger.Conditions>
                    <Condition Binding= "{Binding Path=IsInSearchResults}" Value="False" />
                    <Condition Binding="{Binding Path=IsAncestorOfSearchResultItem }" Value="True" />
                    <Condition Binding="{Binding Path=IsExpanded }" Value="False" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}" Value="True" />
                  </MultiDataTrigger.Conditions>
                  <Setter Property="Foreground" Value="{DynamicResource {x:Static vsShell11:TreeViewColors.BackgroundTextBrushKey}}" />
                </MultiDataTrigger>
                <!-- But for non-expanded, non-selected ancestors of a search result we need the foreground brush which shows up against the HighlightedSpanBrushKey background -->
                <MultiDataTrigger>
                  <MultiDataTrigger.Conditions>
                    <Condition Binding= "{Binding Path=IsInSearchResults}" Value="False" />
                    <Condition Binding="{Binding Path=IsAncestorOfSearchResultItem }" Value="True" />
                    <Condition Binding="{Binding Path=IsExpanded }" Value="False" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}" Value="False" />
                  </MultiDataTrigger.Conditions>
                  <Setter Property="Foreground" Value="{DynamicResource {x:Static vsShell11:TreeViewColors.HighlightedSpanTextBrushKey}}" />
                </MultiDataTrigger>

                <Trigger SourceName="Bd" Property="Selector.IsSelected" Value="True">
                  <Setter  Property="Background" Value="{DynamicResource VsBrush.ToolWindowBackground}" />
                  <Setter  TargetName="Bd" Property="BorderThickness" Value="2" />
                  <Setter  TargetName="Bd" Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey {x:Type xdb:ExplorerContent}, SearchResultBrush}}" />
                </Trigger>
              </ControlTemplate.Triggers>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>

      <!--Tree View Item Stack Panel Style ************************-->
      <Style x:Key="TreeItemStackPanelStyle" TargetType="{x:Type StackPanel}">
        <Setter Property="Orientation" Value="Horizontal" />
      </Style>

      <!-- EditableContentControl Style *****************************************-->
      <Style        x:Key="EditableContentControlStyle"
                    TargetType="{x:Type coreCtrls:EditableContentControl}">
        <Setter Property="Text" Value="{Binding EditableName, Mode=TwoWay}" />
        <Setter Property="IsInEditMode" Value="{Binding IsInEditMode, Mode=TwoWay}" />
        <Setter Property="IsEditModeAllowed" Value="{Binding IsEditableInline, Mode=OneWay}" />
        <Setter Property="AutomationProperties.AutomationId" Value="EditableContentControl" />
      </Style>

      <!-- TreeItemText Style *************************************-->
      <Style        x:Key="TreeItemTextStyle"
                    TargetType= "{x:Type TextBlock}" >
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="Text" Value="{Binding Path=Name}" />
        <Setter Property="ToolTip" Value="{Binding Path=ToolTipText}" />
        <Setter Property="ToolTipService.ShowDuration" Value="3600000" />
      </Style>

      <!--**********************************************************-->
      <!--Hierarchical Data Templates ******************************-->
      <!--**********************************************************-->
      <!-- Note: it is very important that the x:Key value for each 
           HierarchicalDataTemplate match exactly the class name of 
           the underlying ExplorerEFElement class. This is depended
           upon by the ExplorerSelector ItemTemplateSelector 
           functionality for ExplorerTreeViewItem.                  -->

      <!-- Root Item -->
      <HierarchicalDataTemplate x:Key=              "ExplorerRootNode"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <!-- Entity Model Items -->
      <HierarchicalDataTemplate x:Key=              "ExplorerDiagrams"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel            Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock          x:Name=             "Name"
                              Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl     x:Name="IsAncestorOfSearchResultItem"
                              Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerConceptualEntityModel"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerStorageEntityModel"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerConceptualEntityContainer"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerEntityContainerEntitySets"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerEntityContainerAssociationSets"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerAssociationSet"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerFunctionImports"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerFunctionImport"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerEntitySet"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerConceptualEntityType"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <coreCtrls:EditableContentControl Style="{StaticResource EditableContentControlStyle}">
            <TextBlock          x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          </coreCtrls:EditableContentControl>
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerComplexType"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <coreCtrls:EditableContentControl Style="{StaticResource EditableContentControlStyle}">
            <TextBlock          x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          </coreCtrls:EditableContentControl>
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate  x:Key=              "ExplorerDiagram"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <coreCtrls:EditableContentControl Style="{StaticResource EditableContentControlStyle}">
            <TextBlock          x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          </coreCtrls:EditableContentControl>
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerStorageEntityType"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerAssociations"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerConceptualAssociation"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerStorageAssociation"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerFunctions"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerFunction"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerParameter"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerConceptualProperty"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <coreCtrls:EditableContentControl Style="{StaticResource EditableContentControlStyle}">
            <TextBlock          x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          </coreCtrls:EditableContentControl>
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerStorageProperty"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerNavigationProperty"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerTypes"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=               "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerComplexTypes"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=               "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerEntityTypeShape"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <coreCtrls:EditableContentControl Style="{StaticResource EditableContentControlStyle}">
            <TextBlock          x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          </coreCtrls:EditableContentControl>
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerEnumTypes"
                         ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=               "{StaticResource TreeItemStackPanelStyle}">
          <TextBlock            x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

      <HierarchicalDataTemplate x:Key=              "ExplorerEnumType"
                                ItemsSource=        "{Binding Path=Children}">
        <StackPanel             Style=              "{StaticResource TreeItemStackPanelStyle}">
          <coreCtrls:EditableContentControl Style="{StaticResource EditableContentControlStyle}">
            <TextBlock          x:Name=             "Name"
                                Style=              "{StaticResource TreeItemTextStyle}" />
          </coreCtrls:EditableContentControl>
          <ContentControl       x:Name="IsAncestorOfSearchResultItem"
                                Style="{StaticResource IsAncestorOfSearchResultItemStyle}"/>
        </StackPanel>
      </HierarchicalDataTemplate>

    </ResourceDictionary>
  </Grid.Resources>

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

  <Border x:Name="toolbarBorder" Grid.Row="0" Padding="4,3,4,2"
          Background="{DynamicResource VsBrush.CommandBarGradientBegin}"
          vsShell11:ImageThemingUtilities.ImageBackgroundColor="{Binding Path=Background, RelativeSource={RelativeSource Self}, Converter={StaticResource BrushToColorConverter}}">
    <DockPanel x:Name="toolbarPanel">
      <!-- toolbar buttons must be 23x22 pixels (including the border) -->
      <Button x:Name="goSearchButton" DockPanel.Dock="Right"
              x:Uid="goSearchButton"
              Width="22" MinHeight="21"
              VerticalAlignment="Center"
              HorizontalAlignment="Center"
              VerticalContentAlignment="Center"
              HorizontalContentAlignment="Center"
              Margin="2,0,0,0"
              Command="{Binding SearchCommand}"
              ToolTip="{x:Static Design:Resources.ExplorerContent_Search}"
              AutomationProperties.Name="{Binding RelativeSource={RelativeSource Self}, Path=ToolTip}"
              KeyboardNavigation.TabIndex="2">
        <Image Width="16" Height="16">
          <Image.Source>
            <MultiBinding Converter="{StaticResource ThemedImageSourceConverter}">
              <Binding Source="{StaticResource SearchIcon}" />
              <Binding Path="(vsShell11:ImageThemingUtilities.ImageBackgroundColor)" RelativeSource="{RelativeSource Self}" />
              <Binding Source="{x:Static vsShell11:Boxes.BooleanTrue}"/>
            </MultiBinding>
          </Image.Source>
        </Image>
        <Button.Style>
          <Style BasedOn="{StaticResource ToolBarButtonStyle}" TargetType="{x:Type Button}">
            <Style.Triggers>
              <DataTrigger Binding="{Binding ElementName=searchBox, Path=Text }" Value="">
                <Setter Property="Button.IsEnabled" Value="false" />
                <Setter Property="Button.Opacity" Value="0.5" />
              </DataTrigger>
            </Style.Triggers>
          </Style>
        </Button.Style>
      </Button>
      <Border x:Name="comboPanel">
        <Grid>
          <xdb:SearchComboBox x:Name="searchBox"
                    AutomationProperties.Name="{x:Static Design:Resources.ExplorerContent_PromptSearch}"
                    BorderThickness="0.0"
                    Background="{DynamicResource VsBrush.ComboBoxBackground}"
                    Foreground="{DynamicResource VsBrush.ComboBoxGlyph}"
                    KeyboardNavigation.TabIndex="1"
                    Margin="0,1,0,2"
                    Style="{DynamicResource {x:Static ToolBar.ComboBoxStyleKey}}"
                    Width="{Binding ElementName=comboPanel, Path=ActualWidth}"
                    VerticalAlignment=  "Center"
                    Loaded=             "OnDropDownLoaded"
                    DropDownOpened=     "OnDropDownOpened"
                    KeyDown=            "OnKeyDownHandler"
                    IsEditable=         "True"
                    IsEnabled=          "{Binding HasLoadException, Converter={StaticResource NegateConverter}}"
                    IsTextSearchEnabled="False"
                    StaysOpenOnEdit=    "True" />
          <!-- Note: searchPrompt will only be visible if searchBox.IsHitTestVisible is set to false -->
          <TextBlock x:Name="searchPrompt" x:Uid="searchPrompt" Padding="5,5,20,0" IsHitTestVisible="False"
                     AutomationProperties.Name="{x:Static Design:Resources.ExplorerContent_PromptSearch}"
                     MaxWidth="{Binding ElementName=comboPanel, Path=ActualWidth}"
                     TextTrimming="CharacterEllipsis"
                     Background="{DynamicResource VsBrush.ComboBoxBackground}"
                     Foreground="{DynamicResource VsBrush.GrayText}"
                     Text="{x:Static Design:Resources.ExplorerContent_PromptSearch}" >
            <TextBlock.Style>
              <Style TargetType="{x:Type TextBlock}">
                <Setter Property="TextBlock.Visibility" Value="Collapsed" />
                <Style.Triggers>
                  <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                      <Condition Binding="{Binding ElementName=searchBox, Path=Text }" Value="" />
                      <Condition Binding="{Binding ElementName=searchBox, Path=IsKeyboardFocusWithin }" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <MultiDataTrigger.Setters>
                      <Setter Property="Visibility" Value="Visible" />
                    </MultiDataTrigger.Setters>
                  </MultiDataTrigger>
                </Style.Triggers>
              </Style>
            </TextBlock.Style>
          </TextBlock>
        </Grid>
      </Border>
    </DockPanel>
  </Border>

  <Border x:Name="searchBar" Grid.Row ="1"
          Visibility="Collapsed"
          Style="{StaticResource SearchBarStyle}"
          Background="{DynamicResource VsBrush.CommandBarGradientBegin}">
    <DockPanel>
      <StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
        <Separator  Style="{DynamicResource {x:Static ToolBar.SeparatorStyleKey}}"/>
        <Button x:Name="searchNavPrevious"
                x:Uid="searchNavPrevious"
                Style="{StaticResource ToolBarButtonStyle}"
                MinWidth="16" MinHeight="16"
                ToolTip="{x:Static Design:Resources.ExplorerContent_SearchNavPrev}"
                AutomationProperties.Name="{Binding RelativeSource={RelativeSource Self}, Path=ToolTip}"
                IsEnabled="{Binding CanGotoPreviousResult}"
                Command="{Binding SelectPreviousSearchResult}"
                KeyboardNavigation.TabIndex="3">
          <Path Fill="{DynamicResource VsBrush.CommandBarTextActive}"
                Style="{StaticResource ExplorerSearchPrevNavPathStyle}"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Data="M 3 0 L 0 3 L 6 3 Z"/>
        </Button>
        <Button x:Name="searchNavNext"
                x:Uid="searchNavNext"
                Style="{StaticResource ToolBarButtonStyle}"
                MinWidth="16" MinHeight="16"
                ToolTip="{x:Static Design:Resources.ExplorerContent_SearchNavNext}"
                AutomationProperties.Name="{Binding RelativeSource={RelativeSource Self}, Path=ToolTip}"
                IsEnabled="{Binding CanGotoNextResult}"
                Command="{Binding SelectNextSearchResult}"
                KeyboardNavigation.TabIndex="4">
          <Path Fill="{DynamicResource VsBrush.CommandBarTextActive}"
                Style="{StaticResource ExplorerSearchNextNavPathStyle}"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Data="M 0 0 L 3 3 L 6 0 Z"/>
        </Button>
        <Separator  Style="{DynamicResource {x:Static ToolBar.SeparatorStyleKey}}"/>
        <Button x:Name="resetSearchButton"
                x:Uid="resetSearchButton"
                        MinWidth="16" MinHeight="16"
                        ToolTip="{x:Static Design:Resources.ExplorerContent_ClearSearch}"
                        AutomationProperties.Name="{Binding RelativeSource={RelativeSource Self}, Path=ToolTip}"
                        Margin="0,0,4,0"
                        Style="{StaticResource ToolBarButtonStyle}"
                        Command="{Binding ResetSearchCommand}"
                        VerticalAlignment="Center"
                        KeyboardNavigation.TabIndex="5">
          <Path Stroke="{DynamicResource VsBrush.CommandBarTextActive}"
                StrokeThickness="1.5"
                StrokeStartLineCap="Round"
                StrokeEndLineCap="Round"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Data="M 1 1 L 7 7 M 1 7 L 7 1"/>
        </Button>
      </StackPanel>
      <TextBlock Padding="9,4,2,4" x:Name="searchBarText" VerticalAlignment="Center"
          TextTrimming="CharacterEllipsis" Foreground="{DynamicResource VsBrush.GrayText}">
      </TextBlock>
    </DockPanel>
  </Border>

  <xdb:SearchAdornerDecorator Grid.Row= "2"
                             x:Name="searchAdornerDecorator"
                             Visibility="{Binding Path=HasLoadException, Converter={StaticResource BoolToHiddenConverter}}">
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
      </Grid.ColumnDefinitions>
      <TreeView x:Name="explorerTreeView"
                Background="{DynamicResource VsBrush.ToolWindowTabSelectedTab}"
                Foreground="{DynamicResource VsBrush.ToolWindowTabSelectedText}"
                Grid.Column="0"
                x:Uid="ExplorerTreeView"
                VirtualizingStackPanel.IsVirtualizing="False"
                KeyboardNavigation.TabIndex="6"
                BorderThickness="0"
                Padding="0,2,0,0"
                vsShell11:ImageThemingUtilities.ImageBackgroundColor="{Binding Path=Background, RelativeSource={RelativeSource Self}, Converter={StaticResource BrushToColorConverter}}">

        <xdb:ExplorerTreeViewItem    x:Name="explorerTreeRoot"
                            ItemsSource= "{Binding Path=Children}"
                            ItemTemplateSelector="{StaticResource ExplorerSelector}"
                            Header=      "{Binding Path=Name}"
                            IsSelected=  "True"
                            IsExpanded=  "True"
                            Collapsed=   "OnTreeViewItemCollapsed"
                            Expanded=    "OnTreeViewItemExpanded">
        </xdb:ExplorerTreeViewItem>
      </TreeView>
      <ContentControl x:Name="searchTicksTrack"
                      Grid.Column="0"
                      Focusable="false"
                      HorizontalAlignment="Right"
                      MinWidth="{DynamicResource {x:Static SystemParameters.ScrollWidthKey}}"
                      MaxWidth="{DynamicResource {x:Static SystemParameters.ScrollWidthKey}}"
                      Visibility="Collapsed"/>
    </Grid>
  </xdb:SearchAdornerDecorator>

</xdb:ExplorerContent>
