diff --git a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineView.xaml b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineView.xaml index fd7f7098c264b..9b40076652d27 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineView.xaml +++ b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineView.xaml @@ -10,6 +10,8 @@ xmlns:imagecatalog="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.ImageCatalog" xmlns:vsui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0" xmlns:platformimaging="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Imaging" + xmlns:ctrls="clr-namespace:Microsoft.VisualStudio.Shell.Controls;assembly=Microsoft.VisualStudio.Shell.Styles" + xmlns:styles="clr-namespace:Microsoft.VisualStudio.Shell.Styles;assembly=Microsoft.VisualStudio.Shell.Styles" xmlns:ComponentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" d:DataContext="{d:DesignInstance Type=self:DocumentOutlineViewModel}" mc:Ignorable="d" @@ -60,11 +62,6 @@ - - @@ -84,7 +81,7 @@ to mean that we should navigate to that item. By only hearing when the source is updated (meaning the user actually clicked on the tree view item, not that we programmatically set it) we only actual perform the navigation on user interaction. --> - - - - - - - - - - - - - - - - - + + + + - - - - - - + diff --git a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineView.xaml.cs b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineView.xaml.cs index c9324de888e4a..79c3d9f220b4e 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineView.xaml.cs +++ b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineView.xaml.cs @@ -73,6 +73,16 @@ public DocumentOutlineView( _windowSearchHost = windowSearchHostFactory.CreateWindowSearchHost(SearchHost); _windowSearchHost.SetupSearch(this); + // Apply Fluent style to the search control + foreach (UIElement child in SearchHost.Children) + { + if (child is Control control) + { + control.SetResourceReference(FrameworkElement.StyleProperty, "SearchControlToolBarStyleKey"); + break; + } + } + this.PreviewKeyDown += OnPreviewKeyDown; viewTracker.CaretMovedOrActiveViewChanged += ViewTracker_CaretMovedOrActiveViewChanged; } @@ -357,16 +367,12 @@ private void SymbolTreeItem_Selected(object sender, RoutedEventArgs e) double renderHeight; if (item.IsExpanded && item.HasItems) { - // The first child is a container. Inside the container are three children: - // 1. The expander - // 2. The border for the header item - // 3. The container for the children - // - // For expanded items, we want to only consider the render heigh of the header item, since that is - // the specific item which is selected. - var container = VisualTreeHelper.GetChild(item, 0); - var border = VisualTreeHelper.GetChild(container, 1); - renderHeight = ((UIElement)border).RenderSize.Height; + // For expanded items, we want to only consider the render height of the header area, since that is + // the specific item which is selected, not the expanded children below it. + // The Fluent TreeViewItem tracks header height automatically. + renderHeight = item is Shell.Controls.TreeViewItem { HeaderHeight: > 0 and var headerHeight } + ? headerHeight + : item.RenderSize.Height; } else { diff --git a/src/VisualStudio/Core/Def/DocumentOutline/VirtualizingTreeView.cs b/src/VisualStudio/Core/Def/DocumentOutline/VirtualizingTreeView.cs deleted file mode 100644 index cebae0913d1dc..0000000000000 --- a/src/VisualStudio/Core/Def/DocumentOutline/VirtualizingTreeView.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Windows.Automation.Peers; -using System.Windows.Controls; - -namespace Microsoft.VisualStudio.LanguageServices.DocumentOutline; - -// Provide a workaround for https://github.com/dotnet/wpf/issues/122 when using virtualized TreeView. -internal sealed class VirtualizingTreeView : TreeView -{ - public VirtualizingTreeView() - { - // Two important properties are being set for TreeView: - // We set IsVirtualizing to "true" so that WPF only generates internal data-structures elements that are visible. - // Setting VirtualizationMode to "Recycling" ensures that WPF internal data is reused as items scroll in and out of view. - VirtualizingPanel.SetIsVirtualizing(this, true); - VirtualizingPanel.SetVirtualizationMode(this, VirtualizationMode.Recycling); - } - - protected override AutomationPeer OnCreateAutomationPeer() - => new VirtualizingTreeViewAutomationPeer(this); - - public sealed class VirtualizingTreeViewAutomationPeer(TreeView owner) - : TreeViewAutomationPeer(owner) - { - protected override ItemAutomationPeer CreateItemAutomationPeer(object item) - => new VirtualizingTreeViewDataItemAutomationPeer(item, this, null); - } - - public sealed class VirtualizingTreeViewDataItemAutomationPeer(object item, ItemsControlAutomationPeer itemsControlAutomationPeer, TreeViewDataItemAutomationPeer? parentDataItemAutomationPeer) - : TreeViewDataItemAutomationPeer(item, itemsControlAutomationPeer, parentDataItemAutomationPeer) - { - protected override string GetNameCore() - { - try - { - return base.GetNameCore(); - } - catch (NullReferenceException) - { - // https://github.com/dotnet/wpf/issues/122 - return ""; - } - } - } -} diff --git a/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj b/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj index dc06773ef93bc..40ec5be57bd92 100644 --- a/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj +++ b/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj @@ -113,6 +113,7 @@ +