From 95788cdf8de7beb3398696d318752a26d3adc8b8 Mon Sep 17 00:00:00 2001 From: Bastian Schmidt Date: Sun, 13 Dec 2020 12:13:59 +0100 Subject: [PATCH] Fixes #877 --- Changelog.md | 6 ++++ Fluent.Ribbon.Showcase/TestContent.xaml | 2 +- Fluent.Ribbon/Controls/StartScreen.cs | 45 ++++++++++++------------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/Changelog.md b/Changelog.md index 09eb832a1..0a9ab49cc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,11 @@ # Changelog for Fluent.Ribbon +## 8.0.3 + +- ### Bug fixes + + - [#877](../../issues/877) - Titlebar and Quick-Access broken when using StartScreen + ## 8.0.2 - ### Bug fixes diff --git a/Fluent.Ribbon.Showcase/TestContent.xaml b/Fluent.Ribbon.Showcase/TestContent.xaml index e180b4317..46a92dcaa 100644 --- a/Fluent.Ribbon.Showcase/TestContent.xaml +++ b/Fluent.Ribbon.Showcase/TestContent.xaml @@ -155,7 +155,7 @@ You can close the start screen by either clicking the button below or by pressing ESC Close start screen diff --git a/Fluent.Ribbon/Controls/StartScreen.cs b/Fluent.Ribbon/Controls/StartScreen.cs index 00bd6f197..10714a695 100644 --- a/Fluent.Ribbon/Controls/StartScreen.cs +++ b/Fluent.Ribbon/Controls/StartScreen.cs @@ -1,4 +1,4 @@ -// ReSharper disable once CheckNamespace +// ReSharper disable once CheckNamespace namespace Fluent { using System.Windows; @@ -9,15 +9,13 @@ namespace Fluent /// public class StartScreen : Backstage { - private bool previousTitleBarIsCollapsed; - /// /// Indicates whether the has aleaady been shown or not. /// public bool Shown { - get { return (bool)this.GetValue(ShownProperty); } - set { this.SetValue(ShownProperty, value); } + get => (bool)this.GetValue(ShownProperty); + set => this.SetValue(ShownProperty, value ? BooleanBoxes.TrueBox : BooleanBoxes.FalseBox); } /// Identifies the dependency property. @@ -36,17 +34,19 @@ private static void OnVisibilityChanged(DependencyObject d, DependencyPropertyCh ((StartScreen)d).UpdateIsTitleBarCollapsed(); } + // This is required for scenarios like in #445 where the start screen is shown, but never hidden through Hide() but made hidden by changing just it's visibility. private void UpdateIsTitleBarCollapsed() { - var parentRibbon = GetParentRibbon(this); - - if (parentRibbon?.TitleBar != null) + if (this.IsOpen == false) { - if (this.IsOpen) - { - parentRibbon.TitleBar.IsCollapsed = this.Visibility == Visibility.Visible; - } + return; } + + var parentRibbon = GetParentRibbon(this); + + parentRibbon?.TitleBar?.SetCurrentValue(RibbonTitleBar.IsCollapsedProperty, this.Visibility == Visibility.Visible + ? BooleanBoxes.TrueBox + : BooleanBoxes.FalseBox); } /// @@ -63,16 +63,16 @@ protected override bool Show() return false; } - var parentRibbon = GetParentRibbon(this); + this.Shown = base.Show(); - if (parentRibbon?.TitleBar != null) + if (this.Shown) { - this.previousTitleBarIsCollapsed = parentRibbon.TitleBar.IsCollapsed; + var parentRibbon = GetParentRibbon(this); - this.UpdateIsTitleBarCollapsed(); + parentRibbon?.TitleBar?.SetCurrentValue(RibbonTitleBar.IsCollapsedProperty, BooleanBoxes.TrueBox); } - return this.Shown = base.Show(); + return this.Shown; } /// @@ -80,16 +80,15 @@ protected override bool Show() /// protected override void Hide() { - var wasOpen = this.IsOpen; + var wasShown = this.Shown; + base.Hide(); - if (wasOpen) + if (wasShown) { var parentRibbon = GetParentRibbon(this); - if (parentRibbon?.TitleBar != null) - { - parentRibbon.TitleBar.IsCollapsed = this.previousTitleBarIsCollapsed; - } + + parentRibbon?.TitleBar?.ClearValue(RibbonTitleBar.IsCollapsedProperty); } } }