Skip to content

Commit

Permalink
Fixes #240 by only closing backstage when DissmissPopupMode is Always
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Jan 8, 2016
1 parent 754d0a2 commit 015924f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- [#236](../../issues/236) - Window size is wrong when window is maximized, backstage is closed and window should be restored to normal size
- [#237](../../issues/237) - Ribbon Buttons with large text cut off a few pixels
- [#238](../../issues/238) - New WindowChrome does not work correctly on Windows 7
- [#240](../../issues/240) - Backstage closes when popup is dismissed inside backstage
- OpenBackstage command was not acting on the correct backstage in a multiple backstage scenario (thanks to @maurosampietro)

- ### Enhancements
Expand Down
7 changes: 7 additions & 0 deletions Fluent.Ribbon/Controls/Backstage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ public Backstage()

private void OnPopupDismiss(object sender, DismissPopupEventArgs e)
{
// Only close backstage when popups should always be closed.
// "Always" applies to controls marked with IsDefinitive for example.
if (e.DismissMode != DismissPopupMode.Always)
{
return;
}

this.IsOpen = false;
}

Expand Down
27 changes: 2 additions & 25 deletions Fluent.Ribbon/Controls/BackstageTabControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,14 @@ static object OnCoerceStyle(DependencyObject d, object basevalue)
/// </summary>
public BackstageTabControl()
{
this.Loaded += this.OnLoaded;
this.Unloaded += this.OnUnloaded;

// Fixed incoreect menu showing
// Fixed incorect menu showing
this.ContextMenu = new ContextMenu
{
Width = 0,
Height = 0,
HasDropShadow = false
};
this.ContextMenu.Opened += delegate { ContextMenu.IsOpen = false; };
this.ContextMenu.Opened += delegate { this.ContextMenu.IsOpen = false; };
}

#endregion
Expand Down Expand Up @@ -417,26 +414,6 @@ private void OnGeneratorStatusChanged(object sender, EventArgs e)
}
}

private void OnPopupDismiss(object sender, DismissPopupEventArgs e)
{
var backstage = LogicalTreeHelper.GetParent(this);

if (backstage != null)
{
PopupService.RaiseDismissPopupEvent(backstage, DismissPopupMode.Always);
}
}

private void OnLoaded(object sender, RoutedEventArgs e)
{
this.AddHandler(PopupService.DismissPopupEvent, (DismissPopupEventHandler)this.OnPopupDismiss);
}

private void OnUnloaded(object sender, RoutedEventArgs e)
{
this.RemoveHandler(PopupService.DismissPopupEvent, (DismissPopupEventHandler)this.OnPopupDismiss);
}

#endregion
}
}

0 comments on commit 015924f

Please sign in to comment.