Skip to content

Commit

Permalink
Fixes #840 by fixing logical tree issues
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Aug 15, 2020
1 parent 71d2e00 commit 829c498
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 20 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 6 additions & 16 deletions Fluent.Ribbon/Controls/Ribbon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,10 @@ private static void OnContextMenuOpened(object sender, RoutedEventArgs e)
private ObservableCollection<Key> keyTipKeys;

// Collection of contextual tab groups
private ItemCollectionWithLogicalTreeSupport<RibbonContextualTabGroup> contextualGroups;
private ObservableCollection<RibbonContextualTabGroup> contextualGroups;

// Collection of tabs
private ItemCollectionWithLogicalTreeSupport<RibbonTabItem> tabs;
private ObservableCollection<RibbonTabItem> tabs;

// Collection of toolbar items
private ObservableCollection<UIElement> toolBarItems;
Expand Down Expand Up @@ -824,13 +824,13 @@ public double QuickAccessToolBarHeight
/// Gets collection of contextual tab groups
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ItemCollectionWithLogicalTreeSupport<RibbonContextualTabGroup> ContextualGroups
public ObservableCollection<RibbonContextualTabGroup> ContextualGroups
{
get
{
if (this.contextualGroups == null)
{
this.contextualGroups = new ItemCollectionWithLogicalTreeSupport<RibbonContextualTabGroup>(this);
this.contextualGroups = new ObservableCollection<RibbonContextualTabGroup>();
}

return this.contextualGroups;
Expand All @@ -841,13 +841,13 @@ public ItemCollectionWithLogicalTreeSupport<RibbonContextualTabGroup> Contextual
/// gets collection of ribbon tabs
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ItemCollectionWithLogicalTreeSupport<RibbonTabItem> Tabs
public ObservableCollection<RibbonTabItem> Tabs
{
get
{
if (this.tabs == null)
{
this.tabs = new ItemCollectionWithLogicalTreeSupport<RibbonTabItem>(this);
this.tabs = new ObservableCollection<RibbonTabItem>();
}

return this.tabs;
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions Fluent.Ribbon/Controls/RibbonGroupsContainerScrollViewer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ReSharper disable once CheckNamespace
namespace Fluent
{
using System.Windows;
using System.Windows.Controls;

/// <summary>
/// Represents a <see cref="ScrollViewer"/> specific to <see cref="RibbonGroupsContainer"/>.
/// </summary>
public class RibbonGroupsContainerScrollViewer : ScrollViewer
{
static RibbonGroupsContainerScrollViewer()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(RibbonGroupsContainerScrollViewer), new FrameworkPropertyMetadata(typeof(RibbonGroupsContainerScrollViewer)));
}
}
}
2 changes: 1 addition & 1 deletion Fluent.Ribbon/Controls/RibbonScrollViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Fluent
using System.Windows.Media;

/// <summary>
/// Represents ScrollViewer with modified hit test
/// Represents <see cref="ScrollViewer"/> with modified hit test
/// </summary>
public class RibbonScrollViewer : ScrollViewer
{
Expand Down
2 changes: 1 addition & 1 deletion Fluent.Ribbon/Controls/RibbonTabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public string KeyTip
/// <summary>
/// Gets ribbon groups container
/// </summary>
public ScrollViewer GroupsContainer { get; } = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Disabled };
public ScrollViewer GroupsContainer { get; } = new RibbonGroupsContainerScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Disabled };

/// <summary>
/// Gets or sets whether ribbon is minimized
Expand Down
2 changes: 2 additions & 0 deletions Fluent.Ribbon/Themes/Common.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@
<Style TargetType="{x:Type Fluent:RibbonTitleBar}" BasedOn="{StaticResource RibbonTitleBarStyle}" />
<Style TargetType="{x:Type Fluent:RibbonTabControl}" BasedOn="{StaticResource RibbonTabControlStyle}" />
<Style TargetType="{x:Type Fluent:QuickAccessToolBar}" BasedOn="{StaticResource QuickAccessToolbarStyle}" />

<Style TargetType="{x:Type Fluent:RibbonGroupsContainerScrollViewer}" BasedOn="{StaticResource Fluent.Ribbon.Styles.RibbonGroupsContainerScrollViewer}" />
</ResourceDictionary>
16 changes: 14 additions & 2 deletions Fluent.Ribbon/Themes/Controls/RibbonScrollViewer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,27 @@

<Style x:Key="ScrollViewerStyle"
TargetType="{x:Type ScrollViewer}">
<Style.Resources>
<Style x:Key="{x:Type ScrollBar}"
TargetType="{x:Type ScrollBar}"
BasedOn="{StaticResource ScrollBarWhite}" />
</Style.Resources>

<Setter Property="Template"
Value="{DynamicResource ScrollViewerControlTemplate}" />

<Style.Triggers>
<Trigger Property="IsEnabled"
Value="false">
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
</Style.Triggers>
<Setter Property="Template"
Value="{DynamicResource ScrollViewerControlTemplate}" />
</Style>

<Style x:Key="Fluent.Ribbon.Styles.RibbonGroupsContainerScrollViewer"
TargetType="{x:Type Fluent:RibbonGroupsContainerScrollViewer}"
BasedOn="{StaticResource RibbonScrollViewer}">
</Style>

<ControlTemplate x:Key="ScrollViewerControlTemplate"
Expand Down

0 comments on commit 829c498

Please sign in to comment.