开发者

how to hide/toggle by default a DockingPane in AvalonDock?

Here is the XAML markup. I'm trying to make by default "tools" pane hidden. I've seen in the tutorial something like this : Command="ad:DockableContentCommands.ToggleAutoHide".

       <ad:DockingManager Name="dockingManager">
        <ad:ResizingPanel Orientation="Horizontal" >

            <ad:ResizingPanel Orientation="Vertical">
                <ad:DockablePane>
                    <ad:DockableContent Title="Events">
                        ....
                    </ad:DockableContent>
                </ad:DockablePane>
            </ad:ResizingPanel>

         开发者_运维知识库   <ad:ResizingPanel Orientation="Horizontal" >
                <ad:DockablePane Name="tools" >
                    <ad:DockableContent Name ="search" > ... </ad:DockableContent>
                    <ad:DockableContent Name ="results" > ... </ad:DockableContent>
                </ad:DockablePane>
            </ad:ResizingPanel>

        </ad:ResizingPanel>
    </ad:DockingManager>

how to hide/toggle by default a DockingPane in markup or code ?

Thanks RR


You probably have figured this out by now but for others this worked for me:

XAML:

       <ad:DockingManager Loaded="dockManager_Loaded">

        <...>

        <ad:DockableContent Name="dockName" >
            <TextBlock Text="Something HERE"/>
        </ad:DockableContent>

        <...>

C#:

    private void dockManager_Loaded(object sender, RoutedEventArgs e)
    {
         dockName.ToggleAutoHide();
    }
    private void aButton_Click(object sender, RoutedEventArgs e)
    {
         dockName.Activate();
    }


I know that it's not the best way, but you can setup your layout in application (make DockingPane autoHidden), save layout and then load it on start.


Xaml:

<ad:DockingManager Name="dockingManager"                        
                   Loaded="OnDockManagerLoaded" 
                   Mouse.MouseDown="dockingManager_MouseDown">
     <ad:ResizingPanel Orientation="Vertical">
          <ad:DockablePane x:Name="chartDockablePane">
               <ad:DockableContent x:Name="chartDockableContent" 
                                   DockableStyle="AutoHide">
                     <..some content/>
                </ad:DockableContent>
           </ad:DockablePane>
    </ad:ResizingPanel>
</ad:DockingManager>

cs code behind:

private bool _forcedToAutoHide;

private void OnDockManagerLoaded(object sender, RoutedEventArgs e)
{
    chartDockablePane.ToggleAutoHide();
    _forcedToAutoHide = true;
}

private void dockingManager_MouseDown(object sender, MouseButtonEventArgs e)
{
    if (!_forcedToAutoHide)
    return;
    _forcedToAutoHide = false;
    chartDockableContent.Activate();
    chartDockablePane.ToggleAutoHide();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜