Skip to content

Commit 8dfde7b

Browse files
committed
Selecting a new LayoutAnchorableTabPanel from an auto sized width panel, will no longer undock the LayoutAnchorableTabPanel.
1 parent 896bbc6 commit 8dfde7b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class LayoutAnchorableTabItem : Control
2828

2929
private bool _isMouseDown = false;
3030
private static LayoutAnchorableTabItem _draggingItem = null;
31+
private static bool _cancelMouseLeave = false;
3132

3233
#endregion
3334

@@ -146,6 +147,10 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
146147
_isMouseDown = false;
147148
_draggingItem = null;
148149
}
150+
else
151+
{
152+
_cancelMouseLeave = false;
153+
}
149154
}
150155

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

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

169176
_isMouseDown = false;
177+
_cancelMouseLeave = false;
170178
}
171179

172180
protected override void OnMouseEnter( MouseEventArgs e )
@@ -215,6 +223,11 @@ internal static void ResetDraggingItem()
215223
_draggingItem = null;
216224
}
217225

226+
internal static void CancelMouseLeave()
227+
{
228+
_cancelMouseLeave = true;
229+
}
230+
218231
#endregion
219232
}
220233
}

source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutContent.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This program is provided to you under the terms of the Microsoft Public
2222
using System.Globalization;
2323
using System.Windows.Media;
2424
using System.ComponentModel;
25-
25+
using Xceed.Wpf.AvalonDock.Controls;
2626

2727
namespace Xceed.Wpf.AvalonDock.Layout
2828
{
@@ -159,6 +159,7 @@ public bool IsSelected
159159
parentSelector.SelectedContentIndex = _isSelected ? parentSelector.IndexOf( this ) : -1;
160160
OnIsSelectedChanged( oldValue, value );
161161
RaisePropertyChanged( "IsSelected" );
162+
LayoutAnchorableTabItem.CancelMouseLeave();
162163
}
163164
}
164165
}

0 commit comments

Comments
 (0)