WindowActivate event trigger on already selected window

Docking/MDI for WPF Forum

Posted 13 years ago by Bret Naughton
Version: 11.1.0542
Avatar
Hi, I have built an application that allows a user to create on the fly, toolwindows within the main DockSite - each of these toolwindows also has a docksite within it.

Now I also allow the user to select the toolwindow and create child toolwindows within the selected parent toolwindow.

So, in this example, the user could create 2 top level toolwindows (A & B) and within A, create 2 children toolwindows (A-1 & A-2) and within B, 3 child toolwindows (B-1 & B-2 & B-3).

I am using the WindowActivatedEvent at the main Window level to detect on creation and selection of the toolwindows, and I run some code on the trigger to set headers & other things required by the app depending on the toolwindow selected.

My problem is that I would like this code to be run every time a toolwindow is selected, whether it is already activated or not. What I am finding is that if I select toolwindow A-1, the windowactivated event is triggered (and therefore my code is run). If I select B-2, again this is triggered OK. Problem comes when I then select A-1 again, I suppose because it is already the active window in the parent A toolwindow.

I can't seem to find an event for selection (based on the fact that it is already selected). Appreciate any advice on this.

Bret

I

Within each of these child toolwindows I also create a docksite, I also allow the user to create nested

Comments (4)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bret,

You are correct, since A-1 is already the active window in the nested DockSite it will not be activated again. It sounds like you may need to use the GotKeyboardFocus event, instead of the WindowActivated again. If you do that, then you'd need to use VisualTreeHelperExtended to search up the visual tree to find the associated DockingWindow and/or DockingWindowContainer (the latter of which has a SelectedWindow property).


Actipro Software Support

Posted 13 years ago by Bret Naughton
Avatar
Thanks very much, that works brilliantly. It has also fixed an issue I had where my ribbon buttons were not updating/activating correctly. I guess because of the issue of no event being triggered on selecting the already activated window.

Thanks Again,
Bret
Posted 10 years ago by Jay Hill
Avatar

It would be really helpful to us as well if either a DockingWindow or the DockSite raised an event when it was "reactivated." Something is clearly happening, because in a tabbed MDI scenario the tab highlight changes, but there seems to be no way to detect it short of the hacky visual tree search.

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

Hi Jay,

Can you describe your scenario in more detail, or maybe even post a simple XAML snippet that we could run to see your setup?


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.