Skip to content

Commit

Permalink
Fixes #228 by recreating the backstage adorner if it's parent Adorner…
Browse files Browse the repository at this point in the history
…Layer got destroyed
  • Loading branch information
batzen committed Dec 22, 2015
1 parent f0fb328 commit 013dc50
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Fluent.Ribbon/Controls/Backstage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Backstage : RibbonControl
#region Fields

// Adorner for backstage
BackstageAdorner adorner;
private BackstageAdorner adorner;

#endregion

Expand Down Expand Up @@ -154,10 +154,7 @@ private static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChange
}

// Invoke the event
if (backstage.IsOpenChanged != null)
{
backstage.IsOpenChanged(backstage, e);
}
backstage.IsOpenChanged?.Invoke(backstage, e);
}
}

Expand Down Expand Up @@ -339,10 +336,7 @@ private void Show()
}

var content = this.Content as IInputElement;
if (content != null)
{
content.Focus();
}
content?.Focus();
}

private void ShowAdorner()
Expand All @@ -367,6 +361,14 @@ private void HideAdorner()

private void CreateAndAttachBackstageAdorner()
{
// It's possible that we created an adorner but it's parent AdornerLayer got destroyed.
// If that's the case we have to destroy our adorner.
// This fixes #228 Backstage disappears when changing DontUseDwm
if (this.adorner?.Parent == null)
{
this.DestroyAdorner();
}

if (this.adorner != null)
{
return;
Expand Down Expand Up @@ -435,7 +437,7 @@ private void DestroyAdorner()
}

var layer = AdornerLayer.GetAdornerLayer(this);
layer.Remove(this.adorner);
layer?.Remove(this.adorner);

this.adorner.Clear();
this.adorner = null;
Expand Down

0 comments on commit 013dc50

Please sign in to comment.