diff --git a/Changelog.md b/Changelog.md index b4119dadc..481674b69 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/Fluent.Ribbon/Controls/Backstage.cs b/Fluent.Ribbon/Controls/Backstage.cs index f99f7e58f..ed12a270a 100644 --- a/Fluent.Ribbon/Controls/Backstage.cs +++ b/Fluent.Ribbon/Controls/Backstage.cs @@ -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; } diff --git a/Fluent.Ribbon/Controls/BackstageTabControl.cs b/Fluent.Ribbon/Controls/BackstageTabControl.cs index 440481acf..1b6e2259b 100644 --- a/Fluent.Ribbon/Controls/BackstageTabControl.cs +++ b/Fluent.Ribbon/Controls/BackstageTabControl.cs @@ -219,17 +219,14 @@ static object OnCoerceStyle(DependencyObject d, object basevalue) /// 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 @@ -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 } } \ No newline at end of file