Search code examples
c#wpfwpftoolkitavalondockxceed

How to Re-Dock a floating window Programmatically


I'm using AvalonDock for docking feature. The window is able to pulled out from the main application, as floating window. I want to re-dock (programmatically) the floating window back to its place once the parent window unloads.

The sample code is:

 <xcad:DockingManager x:Name="MyDockingManager">
                            <xcad:LayoutRoot x:Name="_layoutRoot">
                                <xcad:LayoutPanel Orientation="Vertical">
                                    <xcad:LayoutAnchorablePaneGroup>
                                        <xcad:LayoutAnchorablePane>
                                            <xcad:LayoutAnchorable ContentId="moduleView" Title="Module View" CanHide="False" CanClose="False" CanAutoHide="False" CanFloat="False">
                                                <Grid>
                                                    <!-- user controls -->
                                                </Grid>
                                            </xcad:LayoutAnchorable>
                                        </xcad:LayoutAnchorablePane>
                                        <xcad:LayoutAnchorablePane>
                                            <xcad:LayoutAnchorable ContentId="liveLog" Title="Live Logs" CanHide="False" CanAutoHide="False" CanClose="False">
                                                <ListView x:Name="MyListView">

                                                </ListView>
                                            </xcad:LayoutAnchorable>
                                        </xcad:LayoutAnchorablePane>
                                    </xcad:LayoutAnchorablePaneGroup>
                                </xcad:LayoutPanel>
                            </xcad:LayoutRoot>
                        </xcad:DockingManager>

Do anyone have idea?


Solution

  • Since you are using code-behind this can be done simply by adding a name to your LayoutAnchorable, e.g.:

    <xcad:LayoutAnchorable x:Name="liveLogPane" ContentId="liveLog" Title="Live Logs" 
        CanHide="False" CanAutoHide="False" CanClose="False">
        <ListView x:Name="MyListView">
    
        </ListView>
    </xcad:LayoutAnchorable>
    

    And then calling the Dock method:

    liveLogPane.Dock();