Skip to content

Commit

Permalink
Fixes #391 by forcing measure on context group and titlebar
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Jan 23, 2017
1 parent 71592ce commit 2ed252e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- [#369](../../issues/369) - "Restore" button in title bar not displayed correctly when application starts maximized
- [#377](../../issues/377) - ToggleButton highlight doesn't match the button size
- [#388](../../issues/388) - QuickAccess item not visible when added from backstage
- [#391](../../issues/391) - QAT items not displayed properly if tab is made visible after initialization

- ### Enhancements
- [#250](../../issues/250) - Enable change/hide of window title foreground
Expand Down
28 changes: 23 additions & 5 deletions Fluent.Ribbon/Controls/RibbonContextualTabGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,20 @@ public Visibility InnerVisibility
}

private static readonly DependencyPropertyKey InnerVisibilityPropertyKey =
DependencyProperty.RegisterReadOnly(nameof(InnerVisibility), typeof(Visibility), typeof(RibbonContextualTabGroup), new PropertyMetadata(VisibilityBoxes.Visible));
DependencyProperty.RegisterReadOnly(nameof(InnerVisibility), typeof(Visibility), typeof(RibbonContextualTabGroup), new PropertyMetadata(VisibilityBoxes.Visible, OnInnerVisibilityChanged));

/// <summary>
/// Using a DependencyProperty as the backing store for InnerVisibility. This enables animation, styling, binding, etc...
/// </summary>
public static readonly DependencyProperty InnerVisibilityProperty = InnerVisibilityPropertyKey.DependencyProperty;

private static void OnInnerVisibilityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var group = (RibbonContextualTabGroup)d;

ForceRedraw(@group);
}

/// <summary>
/// Gets the first visible TabItem in this group
/// </summary>
Expand Down Expand Up @@ -142,9 +149,7 @@ private static void OnVisibilityChanged(DependencyObject d, DependencyPropertyCh

group.UpdateInnerVisiblityAndGroupBorders();

var titleBar = group.Parent as RibbonTitleBar;

titleBar?.InvalidateMeasure();
ForceRedraw(group);
}

/// <summary>
Expand Down Expand Up @@ -330,12 +335,25 @@ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
/// </summary>
private void UpdateInnerVisibility()
{
this.InnerVisibility = this.Visibility == Visibility.Visible && this.Items.Any(item => item.Visibility == Visibility.Visible) ? Visibility.Visible : Visibility.Collapsed;
this.InnerVisibility = this.Visibility == Visibility.Visible && this.Items.Any(item => item.Visibility == Visibility.Visible)
? Visibility.Visible
: Visibility.Collapsed;
}

private void OnParentWindowStateChanged(object sender, EventArgs e)
{
this.IsWindowMaximized = this.parentWidow.WindowState == WindowState.Maximized;
}

private static void ForceRedraw(RibbonContextualTabGroup @group)
{
@group.InvalidateMeasure();
@group.UpdateLayout();

var titleBar = @group.Parent as RibbonTitleBar;

titleBar?.InvalidateMeasure();
titleBar?.UpdateLayout();
}
}
}

0 comments on commit 2ed252e

Please sign in to comment.