From 829c4986bf39a4042aaacd50c62bd5230f248cc4 Mon Sep 17 00:00:00 2001 From: Bastian Schmidt Date: Sat, 15 Aug 2020 15:30:09 +0200 Subject: [PATCH] Fixes #840 by fixing logical tree issues --- Changelog.md | 1 + Fluent.Ribbon/Controls/Ribbon.cs | 22 +++++-------------- .../RibbonGroupsContainerScrollViewer.cs | 17 ++++++++++++++ Fluent.Ribbon/Controls/RibbonScrollViewer.cs | 2 +- Fluent.Ribbon/Controls/RibbonTabItem.cs | 2 +- Fluent.Ribbon/Themes/Common.xaml | 2 ++ .../Themes/Controls/RibbonScrollViewer.xaml | 16 ++++++++++++-- 7 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 Fluent.Ribbon/Controls/RibbonGroupsContainerScrollViewer.cs diff --git a/Changelog.md b/Changelog.md index df1979099..2cd4d7694 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ - [#821](../../issues/821) - Different visual of menu item and submenu item - [#830](../../issues/830) - When a window is set to automatically resize to its content, when its title is set in code, it disappears - [#834](../../issues/834) - InRibbonGallery resizing issue when changing `Visibility` + - [#840](../../issues/840) - Ribbon does not scroll anymore ## 8.0.0 diff --git a/Fluent.Ribbon/Controls/Ribbon.cs b/Fluent.Ribbon/Controls/Ribbon.cs index ca53bc6f1..17165e6f7 100644 --- a/Fluent.Ribbon/Controls/Ribbon.cs +++ b/Fluent.Ribbon/Controls/Ribbon.cs @@ -491,10 +491,10 @@ private static void OnContextMenuOpened(object sender, RoutedEventArgs e) private ObservableCollection keyTipKeys; // Collection of contextual tab groups - private ItemCollectionWithLogicalTreeSupport contextualGroups; + private ObservableCollection contextualGroups; // Collection of tabs - private ItemCollectionWithLogicalTreeSupport tabs; + private ObservableCollection tabs; // Collection of toolbar items private ObservableCollection toolBarItems; @@ -824,13 +824,13 @@ public double QuickAccessToolBarHeight /// Gets collection of contextual tab groups /// [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - public ItemCollectionWithLogicalTreeSupport ContextualGroups + public ObservableCollection ContextualGroups { get { if (this.contextualGroups == null) { - this.contextualGroups = new ItemCollectionWithLogicalTreeSupport(this); + this.contextualGroups = new ObservableCollection(); } return this.contextualGroups; @@ -841,13 +841,13 @@ public ItemCollectionWithLogicalTreeSupport Contextual /// gets collection of ribbon tabs /// [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - public ItemCollectionWithLogicalTreeSupport Tabs + public ObservableCollection Tabs { get { if (this.tabs == null) { - this.tabs = new ItemCollectionWithLogicalTreeSupport(this); + this.tabs = new ObservableCollection(); } return this.tabs; @@ -1906,16 +1906,6 @@ protected override IEnumerator LogicalChildren yield return this.TabControl.ToolbarPanel; } - foreach (var item in this.Tabs.GetLogicalChildren()) - { - yield return item; - } - - foreach (var item in this.ContextualGroups.GetLogicalChildren()) - { - yield return item; - } - if (this.layoutRoot != null) { yield return this.layoutRoot; diff --git a/Fluent.Ribbon/Controls/RibbonGroupsContainerScrollViewer.cs b/Fluent.Ribbon/Controls/RibbonGroupsContainerScrollViewer.cs new file mode 100644 index 000000000..1d2508192 --- /dev/null +++ b/Fluent.Ribbon/Controls/RibbonGroupsContainerScrollViewer.cs @@ -0,0 +1,17 @@ +// ReSharper disable once CheckNamespace +namespace Fluent +{ + using System.Windows; + using System.Windows.Controls; + + /// + /// Represents a specific to . + /// + public class RibbonGroupsContainerScrollViewer : ScrollViewer + { + static RibbonGroupsContainerScrollViewer() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(RibbonGroupsContainerScrollViewer), new FrameworkPropertyMetadata(typeof(RibbonGroupsContainerScrollViewer))); + } + } +} \ No newline at end of file diff --git a/Fluent.Ribbon/Controls/RibbonScrollViewer.cs b/Fluent.Ribbon/Controls/RibbonScrollViewer.cs index b99c5688f..85724f265 100644 --- a/Fluent.Ribbon/Controls/RibbonScrollViewer.cs +++ b/Fluent.Ribbon/Controls/RibbonScrollViewer.cs @@ -5,7 +5,7 @@ namespace Fluent using System.Windows.Media; /// - /// Represents ScrollViewer with modified hit test + /// Represents with modified hit test /// public class RibbonScrollViewer : ScrollViewer { diff --git a/Fluent.Ribbon/Controls/RibbonTabItem.cs b/Fluent.Ribbon/Controls/RibbonTabItem.cs index 0461cf50b..c57d984fa 100644 --- a/Fluent.Ribbon/Controls/RibbonTabItem.cs +++ b/Fluent.Ribbon/Controls/RibbonTabItem.cs @@ -108,7 +108,7 @@ public string KeyTip /// /// Gets ribbon groups container /// - public ScrollViewer GroupsContainer { get; } = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Disabled }; + public ScrollViewer GroupsContainer { get; } = new RibbonGroupsContainerScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Disabled }; /// /// Gets or sets whether ribbon is minimized diff --git a/Fluent.Ribbon/Themes/Common.xaml b/Fluent.Ribbon/Themes/Common.xaml index cff316124..6470038e1 100644 --- a/Fluent.Ribbon/Themes/Common.xaml +++ b/Fluent.Ribbon/Themes/Common.xaml @@ -45,4 +45,6 @@ + +