Active pane is not set correctly when LayoutAnchorablePane is pinned


When you pin an anchorable pane that has been auto hidden, that pane should become active. Instead, the first pane is always active.

  1. Create a WPF app with reference to AvalonDock
  2. Replace MainWindow with code sample below
  3. Build and run
  4. On Anchorable1 tab, click Auto Hide to unpin the panel
  5. Mouseover Anchorable2 tab, and click Auto Hide to pin Anchorable2.
Expected Behavior
Anchorable2 should be active

Actual Behavior
The first pane, Anchorable1, is active

Code Sample
<Window x:Class="WpfTest.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <xcad:DockingManager x:Name="LeftDockingManager" Grid.Column="0" Background="{x:Null}" >
                <xcad:LayoutPanel Orientation="Horizontal" >
                    <xcad:LayoutAnchorablePane DockWidth="350" Name="LeftPanel">
                        <xcad:LayoutAnchorable Title="Anchorable1" CanHide="False" CanFloat="False" CanClose="False" AutoHideMinWidth="350"  >
                            <StackPanel Width="100" Height="100">
                                <TextBlock Text="Anchorable1" />
                        <xcad:LayoutAnchorable Title="Anchorable2" CanHide="False" CanClose="False" CanFloat="False" AutoHideMinWidth="350"  >
                            <StackPanel Width="100" Height="100">
                                <TextBlock Text="Anchorable2" />
                        <xcad:LayoutDocument Title="DocumentPane" CanClose="False" CanFloat="False">
                            <StackPanel Width="100" Height="100">
                                <TextBlock Text="DocumentPane" />
To Fix, add the code in the region below after line 509 in LayoutAnchorable class
Code File: avalondock-102592\Version2.0\Xceed.Wpf.AvalonDock\Layout\LayoutAnchorable.cs
Insert after line 509
                foreach (var anchorableToToggle in parentGroup.Children.ToArray())

                    #region Fix Active Panel
                    // Set Selected to whatever was active when pinned. After pinned, this will become the active tab.
                    if (anchorableToToggle.IsActive) { 
                        previousContainer.SelectedContentIndex = previousContainer.ChildrenCount - 1;


patombe wrote Sep 9, 2013 at 10:00 AM

it's very old and not fixed bug: http://avalondock.codeplex.com/workitem/12763

wrote Nov 6, 2013 at 9:44 AM

slido wrote Nov 6, 2013 at 10:07 AM

you are almost right with your fix,
if you do the pinning with selecting the autohidden Panels explicitly by mousecklick,
your fix does work.

When you pin them from being opened just by mouseover , unfortunately not, but maybe this is much harder to investigate.

Thank you for your hint