Does the DockingManager come with a built-in method for handling Anchorables

删除回忆录丶 提交于 2019-12-10 03:14:40

问题


When setting up AvalonDock with a set of Anchorables, for example:

<a:LayoutRoot>
    <a:LayoutPanel Orientation="Horizontal">    
        <a:LayoutAnchorablePane>
            <a:LayoutAnchorable Title="A1">
                <!-- content -->
            </a:LayoutAnchorable>
            <a:LayoutAnchorable Title="A2">
                <!-- content -->
            </a:LayoutAnchorable>
    </a:LayoutAnchorablePane>
<!-- ... -->

Does the DockingManager (or something else in AvalonDock) come with a built-in way of managing Anchorables that are closed? Are they stored in a collection somewhere so they can be retrieved and shown again?

For example, the user closes the first one from the code above (A1), what happens to it?
How can I display it again?

What's the typical workflow to deal with closing and restoring anchorables?


回答1:


As you added the xceed tag, I assume you're using Avalondock 2.0.

For example, the user closes the first one from the code above (A1), what happens to it?

You anchorable becomes hidden. If you choose to name your anchorable (example: <a:LayoutAnchorable Title="A1" x:Name="myAnchorable">), you'll see in the code of your view that this.myAnchorable.IsHidden becomes true.

How can I display it again?

Call .Show() against your anchorable: this.myAnchorable.Show();


That being said, Avalondock 2.0 is totally different from 1.0 because it now allows to use MVVM (especially bindings) easily. So the best practice would be to not statically add LayoutAnchorable in the XAML, but manage a collection of ViewModels instead (with a binding to the AnchorablesSource property of the DockingManager). Then it's easy to show/hide anchorables because you just have to get/set your ViewModel property that is bound to the Visibility property of LayoutAnchorableItem.

You could look at the WPF example Avalondock provides. It's the project named AvalonDock.MVVMTestApp in their code source.



来源:https://stackoverflow.com/questions/21692918/does-the-dockingmanager-come-with-a-built-in-method-for-handling-anchorables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!