How can I close the Docking Window?

Docking/MDI for WPF Forum

Posted 6 months ago by shaswat soni
Version: 22.1.1
Avatar

How can I close the Docking Window?, Also I tried to place a button inside the docking window, but it didn't get reflected on the UI, is there something I'm missing ?

<docking:DockingWindow Name="spMain"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Height="auto" Width="Auto">

<Grid Name="gridCtrl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Height="auto" Width="auto">
<WindowsFormsHost x:Name="winFormHost" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Height="Auto" Width="Auto"
docking:InteropFocusTracking.IsEnabled="True">
</WindowsFormsHost>

<Button x:Name="closeButton"
Content="Close"
Background="Black"
Foreground="Black"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Height="5" Width="7"
Click="closeButton_Click" Margin="13,0,0,15"
>

</Grid>
</docking:DockingWindow>

</docking:DocumentWindow>

[Modified 6 months ago]

Comments (1)

Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

1) Each docking window has a CloseCommand property on it you can use.  Set your Button's Command property to "{Binding ElementName=spMain, Path=CloseCommand}".

2) Interop controls like WindowsFormsHost always render above WPF content in the same Window/Popup.  That is a design flaw (commonly called the airspace issue) by Microsoft of WPF in general and is unfortunately nothing we can control.  You need to arrange your Button to not overlap the WindowsFormsHost to have it be visible.

3) You should not be creating a docking:DockingWindow in the XAML since that is a base class.  You should only either be creating a docking:ToolWindow or docking:DocumentWindow instead, based on where it is.  Please see our Control Hierarchy documentation topic to learn how to do this properly, and all our samples show proper XAML.


Actipro Software Support

The latest build of this product (v22.1.4) was released 16 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.