Skip to main content Skip to footer

Toggle the Dock State for C1DockControl

Occasionally, our customers ask if the DockState of the C1DockControl can be toggled by double clicking on the control. Answer to this question is Yes. The dock state for the C1DockControl can be toggled on the C1DockControl's MouseDoubleClick event.

However, in this scenario the toggling will take place every time the mouse is double-clicked anywhere in the control. Improvising it further, we have the following implementation in which toggling will occur only if the mouse is double-clicked either on the C1**DockControl's Header or the Header of its TabPages. 

Clicking on any other area of the control will ignore the toggling action. Once the C1DockTabControl is added in the window, you need to handle its 'MouseDoubleClick' event and inside this event, you can toggle the DockMode** using the following code :

'check if the mouse is double-clicked on the C1DockTabItem or the C1DockTabControl  
 'if C1DockTabItem, then handle the Docked state of its parent  
 'if C1DockTabControl, the Docked state of the source itself is handled  

 If TypeOf e.OriginalSource Is TextBlock Then  
      Dim dc As C1DockTabControl  
      If e.Source.[GetType]() = GetType(C1.WPF.Docking.C1DockTabItem) Then  
           dc = TryCast(TryCast(e.Source, C1DockTabItem).Parent, C1DockTabControl)  
      Else  
           dc = TryCast(e.Source, C1DockTabControl)  
      End If  
      If dc.DockMode = DockMode.Docked Then  
           dc.DockMode = DockMode.Floating  
      ElseIf dc.DockMode = DockMode.Floating Then  
           dc.DockMode = DockMode.Docked  
      End If  
 End If