4
Vote

Active pane is not set correctly when LayoutAnchorablePane is pinned

description

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

Repro
  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"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <xcad:DockingManager x:Name="LeftDockingManager" Grid.Column="0" Background="{x:Null}" >
            <xcad:LayoutRoot>
                <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" />
                            </StackPanel>
                        </xcad:LayoutAnchorable>
                        <xcad:LayoutAnchorable Title="Anchorable2" CanHide="False" CanClose="False" CanFloat="False" AutoHideMinWidth="350"  >
                            <StackPanel Width="100" Height="100">
                                <TextBlock Text="Anchorable2" />
                            </StackPanel>
                        </xcad:LayoutAnchorable>
                    </xcad:LayoutAnchorablePane>
                    <xcad:LayoutDocumentPane>
                        <xcad:LayoutDocument Title="DocumentPane" CanClose="False" CanFloat="False">
                            <StackPanel Width="100" Height="100">
                                <TextBlock Text="DocumentPane" />
                            </StackPanel>
                        </xcad:LayoutDocument>
                    </xcad:LayoutDocumentPane>
                </xcad:LayoutPanel>
            </xcad:LayoutRoot>
        </xcad:DockingManager>
    </Grid>
</Window>
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())
                {
                    previousContainer.Children.Add(anchorableToToggle);

                    #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;
                    }
                    #endregion
                }

comments

patombe wrote Sep 9, 2013 at 10:00 AM

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

slido wrote Nov 6, 2013 at 10:07 AM

Hi,
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