PrimaryWindowChanged is not fired when right clicking

Docking/MDI for WPF Forum

Posted 8 years ago by Kasper
Version: 11.2.0552
Platform: .NET 4.0
Environment: Windows 7 (64-bit)
Avatar

Hi guys,

I just discovered a problem that could have lead to a pretty darn serious bug in my application. It appears that the PrimaryWindowChanged event for the TabbedMdiHost is not fired when you right click on it instead of left clicking, but the clicked document IS activated. I use this event to control which file is currently active, so while the content of the newly selected file is displayed, my application will believe that another OpenFile object is currently the one active and save to that filename! 

Since the document window is being activated it from a right click, I can only assume that the event not firing is indeed a bug? All you need to reproduce it is a TabbedMdiHost, a PrimaryWindowChanged and a mouse with more than one button :D

Comments (7)

Answer - Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Kasper,

Thanks for reporting this issue, we have corrected it for the next maintenance release.


Actipro Software Support

Posted 8 years ago by Kasper
Avatar

Seems to work great in the latest release. Thanks guys!

Posted 7 years ago by Kasper
Avatar

Hi guys,

Another situation where this is not happening seems to be when calling TabbedMdiContainer.SelectNextWindow() and TabbedMdiContainer.SelectPreviousWindow(). Could you please look into this for the next maintenance release? :)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Kasper,

Would you please send a sample to our support address containing the bug so that we can debug and make sure to fix the issue to fit your needs?  Please rename any zip file to txt to avoid it being marked as spam.


Actipro Software Support

Posted 7 years ago by Kasper
Avatar

I have absolutely no special needs for this particular case - I simply want the PrimaryWindowChanged event to be fired when calling SelectNextWindow/SelectPreviousWindow, as expected. There are no special circumstances causing this, so my guess is that it should be easy to spot the problem when you have the Docking controls code in front of you. However, in the interest of speeding up the process, I will e-mail you a sample project with the two lines of code I had to write to reproduce the problem :)

Answer - Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Kasper,
We looked at your code and there are a couple things. First, we recommend that containers should never be accessed directly as they are created and destroyed dynamically. Because of this, the SelectNextWindow method is more internal and should have been marked so. Right after it is called internally the caller of that method activates the next window, which you were trying to do. However if you do wish to continue to use the container in the way you are, the following code is more of what you're looking for:

var dockingWindow = MainTabbedMdiContainer.SelectNextWindow() ?? MainTabbedMdiContainer.Items[0] as DockingWindow;

if (dockingWindow != null)

	dockingWindow.Activate();

 
This should achieve the result and have a wrapping effect that returns to the first tab after the last is reached.

[Modified 7 years ago]


Actipro Software Support

Posted 7 years ago by Kasper
Avatar

The code you provided me with seems to work very fine, but if there's a better/more correct way of doing this, then please do let me know :)

The latest build of this product (v2019.1 build 0683) was released 21 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.