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

1

9

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?

Cleotildeclepe answered 11/2, 2014 at 4:9 Comment(0)
U
13

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.

Unpleasant answered 13/2, 2014 at 13:25 Comment(5)
Thank you, this really clears things up for me. Couldn't find it in the docs, and I hadn't looked at the source you mentioned (was looking at the extended toolkit page). The sample really helps. (I'll award in 6 hours, as I can't yet)Cleotildeclepe
Following the binding examples works for most part, although the LayoutContent class of AvalonDock throws NullReference exceptions every time I try to hide a panel (actually, it tries to close it instead of hiding..) and once I hide a panel (setting visible to false, I can never make it visible again). Will probably post this in a separate question soon.Cleotildeclepe
@Cleotildeclepe Did you ever figure out a solution for the null reference on hide? I am running into that issue as well.Boxfish
@Boxfish not really. I did something really evil and just modified the avalondock source to ignore the error. Everything seemed to work fine then, but your mileage may vary. I've run into quite a few other issues with the toolkit as well...Cleotildeclepe
@Cleotildeclepe I was using the default avalondock BooleanToVisibilityConverter, and that uses Visibility.Collapsed as the default when the value is false, not Visibility.Hidden which is what the anchorable expects when it is hidden. I will write a question and answer on Monday when I am in front of the source. In your binding you just have to add the parameter: Visibility={Binding IsVisible, Mode=TwoWay, ConverterParameter={x:Static Visibility.Hidden}, Converter={StaticResource btvc}}Boxfish

© 2022 - 2024 — McMap. All rights reserved.