Skip to content

Commit

Permalink
Fixes #877
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Dec 13, 2020
1 parent 8fc83c9 commit 95788cd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Fluent.Ribbon.Showcase/TestContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<TextBlock VerticalAlignment="Center"
HorizontalAlignment="Center">You can close the start screen by either clicking the button below or by pressing ESC</TextBlock>
<Fluent:Button HorizontalAlignment="Center"
LargeIcon="pack://application:,,,/Fluent.Ribbon.Showcase;component/Images/Exit.png"
LargeIcon="{iconPacks:Material Kind=ExitToApp}"
IsDefinitive="True">Close start screen</Fluent:Button>
</StackPanel>
</Fluent:StartScreenTabControl.RightContent>
Expand Down
45 changes: 22 additions & 23 deletions Fluent.Ribbon/Controls/StartScreen.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace Fluent
{
using System.Windows;
Expand All @@ -9,15 +9,13 @@ namespace Fluent
/// </summary>
public class StartScreen : Backstage
{
private bool previousTitleBarIsCollapsed;

/// <summary>
/// Indicates whether the <see cref="StartScreen"/> has aleaady been shown or not.
/// </summary>
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);
}

/// <summary>Identifies the <see cref="Shown"/> dependency property.</summary>
Expand All @@ -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);
}

/// <summary>
Expand All @@ -63,33 +63,32 @@ 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;
}

/// <summary>
/// Hides the <see cref="StartScreen" />.
/// </summary>
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);
}
}
}
Expand Down

0 comments on commit 95788cd

Please sign in to comment.