How to access WPF Dock Floating Window
Categories: Docking, DotNetBar for WPF
Sometimes it is necessary to get reference to the floating Window object that is created when dockable window is placed into the floating state so you can change the properties on Window, like show-in-task-bar or change its minimum size.
To access floating Window in WPF Dock control follow these steps:
1. Handle DockSite.AfterDocked event
2. Detect your dock window and ensure that it is in floating state
3. Use Window.GetWindow method to retrieve reference to the floating Window instance
Following code shows how to set MinWidth and MinHeight properties on floating Window:
C#:
void MyDockSite_AfterDocked(object sender, DockRoutedEventArgs e) { if (e.DockControl is DockWindowGroup) { DockWindowGroup dg = e.DockControl as DockWindowGroup; if (dg.IsFloating) { Window w = Window.GetWindow(dg); w.MinHeight = 200; w.MinWidth = 200; } } }
VB:
Private Sub MyDockSite_AfterDocked(ByVal sender As Object, ByVal e As DockRoutedEventArgs) If TypeOf e.DockControl Is DockWindowGroup Then Dim dg As DockWindowGroup = TryCast(e.DockControl, DockWindowGroup) If dg.IsFloating Then Dim w As Window = Window.GetWindow(dg) w.MinHeight = 200 w.MinWidth = 200 End If End If End Sub
Related posts:
Leave a Reply!