undocked toolwindow not raising the LostFocus event

Docking/MDI for WPF Forum

Posted 12 years ago by Martin
Version: 11.1.0545
Avatar
when i undock a toolwindow and click on the main window i can see the titlebar of the toolwindow going to a lighter color, but the LostFocus event is not raised. when the toolwindow is docked in the main window everything works fine.

is this a bug and if not how can i determine when the undocked toolwindow loses focus?

<Window x:Class="WpfDockingTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking">
    <Grid>
        <docking:DockSite HorizontalAlignment="Left" Name="dockSite1" VerticalAlignment="Top" Height="311" Width="503" >
            <docking:ToolWindowContainer x:Name="NavigationContainer" docking:DockSite.ControlSize="200,400">
                <docking:ToolWindow LostFocus="ToolWindow_LostFocus">
                </docking:ToolWindow>
            </docking:ToolWindowContainer>
        </docking:DockSite>
    </Grid>
</Window>

Comments (1)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Martin,

The ToolWindow is only responsible for rendering it's associated tab, if any. So if and when the ToolWindow were to get focus, it would have to be inside it's tab, not it's Content (which is presented by the ToolWindowContainer). You could attach to the LostFocus event on the ToolWindowContainer, but you'd need to do so using an attached behavior and an implicit Style for ToolWindowContainer. You could also attach to the LostFocus event of your content instead.

The ToolWindowContainer, TabbedMdiContainer, and SplitContainer elements are added and removed dynamically as windows are moved around the DockSite. For this reason, you cannot simply attach an event handler in your XAML, as that ToolWindowContainer may be removed when it is no longer needed. In addition, you should not give these elements names (i.e. x:Name="NavigationContainer") as this adds a reference from your window to the ToolWindowContainer, which again may be removed from the DockSite and never used again. In this case, your window would refer to a ToolWindowContainer that isn't used and therefore cannot be garbage collected.


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.