You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a very simple test app that has two ribbon tabs. The IsSelected property of these tabs are data bound to two properties. If the data bound property becomes true, a message box is displayed.
But if you close the message box, then the other tabs IsSelected property turns to true somehow, and the another message box gets displayed
boolisFirstSelected;boolisSecondSelected;publicboolIsFirstSelected{get{returnisFirstSelected;}set{if(isFirstSelected!=value){isFirstSelected=value;if(value)MessageBox.Show("IsFirstSelected is now set to true.");}}}publicboolIsSecondSelected{get{returnisSecondSelected;}set{if(isSecondSelected!=value){isSecondSelected=value;if(value)MessageBox.Show("IsSecondSelected is now set to true.");}}}
Just had a look and first thought that it's a ribbon issue, but i think it's not.
Showing a messagebox, and thus causing a modal message loop, when setting a dependency property confuses the WPF input system somehow.
If you show the messagebox async like this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => MessageBox.Show("IsFirstSelected is now set to true.")));
the issue is gone. If you set a breakpoint on the lines showing the messagebox you can see from the call stack that we get a WM_SETFOCUS window message when closing the messagebox which causes wpf the send a PreviewGotKeyboardFocus event to the other tab item.
We have switched from the Microsoft Ribbon (System.Windows.Controls.Ribbon) to this library, and we didn't have this problem with that. That doesn't set IsSelected to true in PreviewGotKeyboardFocus .
In our application, the main content changes when you change from one Tab to another. In some cases that takes a bit of time and a progress bar is displayed. And when the progress bar is closed, then the application starts switching back to the previous tab, and that causes problems.
We'll need to create a workaround, like ignoring the change of the IsSelected property when a change is already underway.
I still think this is a bug. Showing a dialog in one tab's IsSelected property setter sets another tab's IsSelected property to true as a side effect.
RibbonTest.exe!RibbonTest.MainWindow.IsFirstSelected.set(bool value = true) Line 17 C# Fluent.dll!Fluent.RibbonTabItem.OnPreviewGotKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e = {System.Windows.Input.KeyboardFocusChangedEventArgs}) Line 582 C# PresentationFramework.dll!System.Windows.MessageBox.Show(string messageBoxText) Line 135 C# RibbonTest.exe!RibbonTest.MainWindow.IsSecondSelected.set(bool value = true) Line 35 C#
I have a very simple test app that has two ribbon tabs. The IsSelected property of these tabs are data bound to two properties. If the data bound property becomes true, a message box is displayed.
But if you close the message box, then the other tabs IsSelected property turns to true somehow, and the another message box gets displayed
MainWindow.xaml
MainWindow.cs
Source code:
RibbonTest.zip
Environment
The text was updated successfully, but these errors were encountered: