Activated and deactivated with multi MDI-Rafting DockSite

Docking/MDI for WPF Forum

Posted 8 years ago by duyhai707
Version: 11.1.0544
Avatar
Hi,
I used dock site with three document window (name of them 1,2,3).
When I drop document window 3 out to the docksite, at this time, I have two Host
- MDI Host 1 : contain document window 1, 2
- RaftingHost 2 : contain draft doument window 3.
Here's these following step which I executed :

1.Switch to document window 3, one WindowActivated of document window 3 is executed.
2.Switch to document window 2, one WindowActivated of document window 2 is executed.
3.Switch again to document window 3, one WindowActivated of document window 3 is executed.
4.Switch to document window 1, one WindowActivated of document window 2 is executed
and one WindowActivated of document window 1 is executed (not OK)

5.Switch again to document window 2, one WindowActivated of document window 2 is executed.
6.Switch again to document window 3, one WindowActivated of document window 3 is executed.
7.Switch again to document window 2, one WindowActivated of document window 2 is executed.
Question :
1. why we activated two time in step 4?
2. how can we detect one WindowActivated of document window 2 is case of step 7 OR is a case of step 4.

Thanks,
Hai.

[Modified at 07/27/2011 03:47 AM]

[Modified at 07/27/2011 04:48 AM]

Comments (3)

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

The active window follows the keyboard focus. When you move the focus from the floating window to your main window, the main window will restore focus to the element that previously had focus in that window. This is what activates window 2. After it restores focus, it will move the focus based on your mouse click. This is what activates window 1.

If you simply click the titlebar of the main window, you will see that it activates window 2, as it restores focus. Unfortunately, the only way to prevent that would be to prevent WPF from restoring focus. In WPF 4, there is a new Keyboard.DefaultRestoreFocusMode property that you can set to None. But then it would obviously never restore focus.


Actipro Software Support

Posted 8 years ago by duyhai707
Avatar
Hi actipro team,

Thank for your answers.
For question 2 : how can I distinguish that one WindowActivated of document window 2 is a case of step 7 OR is a case of step 4?

Best regards,
Hai.
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Hai,

There is really no way to distinguish them, as in both cases window 2 is receiving focus. You wouldn't be able to tell if it was due to the user selecting it (using the mouse or keyboard or maybe UI automation) or from the main Window passing it focus.

Assuming you don't/can't set DefaultRestoreFocusMode to None, then you may be able to use the Window.Activated event or FocusManager.GetFocusedElement(window) to determine if the docking window being activated was or contains the element that previously had focus in the window.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.