ActiveWindow not Updated whith hosted WinForms-Control in floating window

Docking/MDI for WPF Forum

Posted 4 years ago by Stefan Link
Version: 14.2.0611
Avatar

When hosting a Windows Forms Control inside a WPF DockSite window, the ActiveWindow (and also LastActiveXXXWindow) is not updated properly for floating windows.

Sample:

<Window x:Class="WpfApplication7.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
        xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        Title="MainWindow" Height="350" Width="525">
    <docking:DockSite>
        <docking:Workspace>
            <docking:TabbedMdiHost>
                <docking:TabbedMdiContainer>
                    <docking:DocumentWindow Title="Forms" CanRaft="True">
                        <WindowsFormsHost>
                            <forms:TextBox />
                        </WindowsFormsHost>
                    </docking:DocumentWindow>
                    <docking:DocumentWindow Title="WPF" CanRaft="True">
                        <TextBox />
                    </docking:DocumentWindow>
                </docking:TabbedMdiContainer>
            </docking:TabbedMdiHost>
        </docking:Workspace>
    </docking:DockSite>
</Window>

 To reproduce:

  1. Start the application and attach Snoop, to check the actual values for ActiveWindow and LastActiveXXXWindow.
  2. Make the document window "Forms" floating.
  3. Now switch between the document window "WPF" within the main window and the floating window "Forms" and watch the ActiveWindow and LastActiveXXXWindow properties.

-> In both cases the ActiveWindow and LastActiveDocumentWindow is the "WPF"-window.

Is there a way to get those properties (and the associated events) work in this case?

 

Thanks in advance

Stefan

Comments (2)

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

Hi Stefan,

Check out the "Docking & MDI / Interoperability / WinForms Compatibility" topic in the documentation that comes with the product.  That describes an attached property on InteropFocusTracking that should always be set on any WindowsFormsHost to improve focus tracking, since WPF doesn't properly track focus changes with WinForms controls.  Please try that and see if it resolves the problem.


Actipro Software Support

Posted 4 years ago by Stefan Link
Avatar

Thanks for the answer, we tested the property and for "simple" WinForms UIs this property works.

Unfortunately the property doesn't work for the WinForms UIs (from a third party application) we have to host within our application.

But your source code gave us some clue what to do to "fix" the ActiveWindow and LastActiveXXXWindow properties with a little use of reflection.

The latest build of this product (v2019.1 build 0681) 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.