Skip to content

Commit

Permalink
Selecting a new LayoutAnchorableTabPanel from an auto sized width pan…
Browse files Browse the repository at this point in the history
…el, will no longer undock the LayoutAnchorableTabPanel.
  • Loading branch information
Dirkster99 committed Oct 8, 2019
1 parent 896bbc6 commit 8dfde7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Expand Up @@ -28,6 +28,7 @@ public class LayoutAnchorableTabItem : Control

private bool _isMouseDown = false;
private static LayoutAnchorableTabItem _draggingItem = null;
private static bool _cancelMouseLeave = false;

#endregion

Expand Down Expand Up @@ -146,6 +147,10 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
_isMouseDown = false;
_draggingItem = null;
}
else
{
_cancelMouseLeave = false;
}
}

protected override void OnMouseLeftButtonUp( System.Windows.Input.MouseButtonEventArgs e )
Expand All @@ -163,10 +168,13 @@ protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )

if( _isMouseDown && e.LeftButton == MouseButtonState.Pressed )
{
_draggingItem = this;
// drag the item if the mouse leave is not canceled.
// Mouse leave should be canceled when selecting a new tab to prevent automatic undock when Panel size is Auto.
_draggingItem = !_cancelMouseLeave ? this : null;
}

_isMouseDown = false;
_cancelMouseLeave = false;
}

protected override void OnMouseEnter( MouseEventArgs e )
Expand Down Expand Up @@ -215,6 +223,11 @@ internal static void ResetDraggingItem()
_draggingItem = null;
}

internal static void CancelMouseLeave()
{
_cancelMouseLeave = true;
}

#endregion
}
}
Expand Up @@ -22,7 +22,7 @@
using System.Globalization;
using System.Windows.Media;
using System.ComponentModel;

using Xceed.Wpf.AvalonDock.Controls;

namespace Xceed.Wpf.AvalonDock.Layout
{
Expand Down Expand Up @@ -159,6 +159,7 @@ public bool IsSelected
parentSelector.SelectedContentIndex = _isSelected ? parentSelector.IndexOf( this ) : -1;
OnIsSelectedChanged( oldValue, value );
RaisePropertyChanged( "IsSelected" );
LayoutAnchorableTabItem.CancelMouseLeave();
}
}
}
Expand Down

0 comments on commit 8dfde7b

Please sign in to comment.