Customized close document via keyboard

Docking/MDI for WPF Forum

The latest build of this product (v25.1.2) was released 2 months ago, which was before this thread was created.
Posted 3 days ago by Procam
Version: 25.1.2
Avatar

Hello,

I found this thread:

How to close document window via keyboard

and my question is related to that fiunctionality (to stop that).
I have the following "outer" DockSite:

                <views:CustomDockSite x:Name="dockSite" CanDocumentWindowsFloat="True" FloatingWindowTitle="xxx"
                          WindowsClosing="OnDockSiteWindowsClosing" WindowActivated="OnDockSiteWindowActivated" WindowDeactivated="OnDockSiteWindowDeactivated"
                          AreNewTabsInsertedBeforeExistingTabs="False" AreDocumentWindowsDestroyedOnClose="False" WindowsDragging="OnDockSiteWindowsDragging"
                          DocumentItemContainerStyle="{StaticResource DockingWindowStyle}" DocumentItemsSource="{Binding DocumentViewsService.DocumentViewsOpened}">
						  
						  <!--More code here-->
						  
                    <docking:Workspace x:Name="workspace">
                        <views:CustomTabbedMdiHost/>
                    </docking:Workspace>
						  
						  <!--More code here-->
						  
		</views:CustomDockSite>

and "inner" DockSite:

         <docking:DockSite x:Name="styleDocumentDockSite"
                          WindowsClosing="OnStyleDocumentDockSiteWindowsClosing" WindowActivated="OnStyleDocumentDockSiteWindowActivated" WindowDeactivated="OnStyleDocumentDockSiteWindowDeactivated"
                          AreNewTabsInsertedBeforeExistingTabs="False" AreDocumentWindowsDestroyedOnClose="True"
                          DocumentItemContainerStyle="{StaticResource DockingWindowStyle}" DocumentItemsSource="{Binding Tabs, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" >
            <docking:Workspace>
                <docking:TabbedMdiHost HasTabImages="True" TabStripPlacement="Top"/>
            </docking:Workspace>
        </docking:DockSite>

Please note mainly the DocumentItemsSource for the outer docksite. It is a collection of viewmodels and the view for such viewmodel is the inner docksite. It means we have here docksite contained within other docksite. Is there a way how to stop the default behaviour of Ctrl+F4? Becasue I want to use that for closing the views inside the inner docksite (the command to be bound to the gesture (input binding) is already implemented on my side) but it seems to be somehow blocked by the default behavior.
Btw, when the inner views are active pressing Ctrl+F4 has no effect.

Thanks for your response.

Comments (1)

Posted 3 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The protected virtual DockSite.ProcessDockHostKeyDown method is where some basic keys like Ctrl+F4 are processed.  You could override that method and if you see Ctrl+F4 is in the KeyEventArgs passed in, do not call the base method.  That should prevent our default processing of that key combination, which is to close the primary document in the DockSite that handles the key.  If there is an inner DockSite, and focus is within that somewhere, it would be the one to handle the key.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.