本文主要讲解通过C1DockControl和TabPages头部的鼠标双击事件来修改C1DockControl的停靠状态。
在窗体中添加C1DockTabControl控件之后,我们需要实现它的MouseDoubleClick事件,添加代码来控制C1Docktabcontrol的DockMode属性,从而达到停靠和浮动的显示效果,代码如下:
1 If TypeOf e.OriginalSource Is TextBlock Then 2 Dim dc As C1DockTabControl 3 If e.Source.[GetType]() = GetType(C1.WPF.Docking.C1DockTabItem) Then 4 dc = TryCast(TryCast(e.Source, C1DockTabItem).Parent, C1DockTabControl) 5 Else 6 dc = TryCast(e.Source, C1DockTabControl) 7 End If 8 If dc.DockMode = DockMode.Docked Then 9 dc.DockMode = DockMode.Floating 10 ElseIf dc.DockMode = DockMode.Floating Then 11 dc.DockMode = DockMode.Docked 12 End If 13 End If
运行程序,我们可以得到以下结果: