diff --git a/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs b/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs index d656468f..e5d1fb8c 100644 --- a/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs +++ b/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs @@ -232,15 +232,6 @@ namespace HandyControl.Controls return; } - if (IsAnimationEnabled) - { - HeaderPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, new Duration(TimeSpan.FromMilliseconds(200))); - } - else - { - HeaderPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0)); - } - if (e.Action == NotifyCollectionChangedAction.Add) { for (var i = 0; i < Items.Count; i++) @@ -252,7 +243,6 @@ namespace HandyControl.Controls } _headerBorder?.InvalidateMeasure(); - IsInternalAction = false; } @@ -361,11 +351,11 @@ namespace HandyControl.Controls list.Insert(0, actualItem); if (IsAnimationEnabled) { - HeaderPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, new Duration(TimeSpan.FromMilliseconds(200))); + HeaderPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, new Duration(TimeSpan.FromMilliseconds(200))); } else { - HeaderPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0)); + HeaderPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, new Duration(TimeSpan.FromMilliseconds(0))); } HeaderPanel.ForceUpdate = true; HeaderPanel.Measure(new Size(HeaderPanel.DesiredSize.Width, ActualHeight)); diff --git a/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs b/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs index c0aa5600..ca35a03c 100644 --- a/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs +++ b/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs @@ -280,7 +280,7 @@ namespace HandyControl.Controls RaiseEvent(argsClosing); if (argsClosing.Cancel) return; - TabPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, parent.IsAnimationEnabled + TabPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, parent.IsAnimationEnabled ? new Duration(TimeSpan.FromMilliseconds(200)) : new Duration(TimeSpan.FromMilliseconds(1))); @@ -302,7 +302,7 @@ namespace HandyControl.Controls if (parent.IsDraggable && !ItemIsDragging && !_isDragging) { parent.UpdateScroll(); - TabPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0)); + TabPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, new Duration(TimeSpan.FromSeconds(0))); _mouseDownOffsetX = RenderTransform.Value.OffsetX; _scrollHorizontalOffset = parent.GetHorizontalOffset(); var mx = TranslatePoint(new Point(), parent).X + _scrollHorizontalOffset; @@ -407,6 +407,7 @@ namespace HandyControl.Controls list.Remove(item); parent.IsInternalAction = true; list.Insert(index, item); + _tabPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, new Duration(TimeSpan.FromMilliseconds(0))); TabPanel.CanUpdate = true; TabPanel.ForceUpdate = true; TabPanel.Measure(new Size(TabPanel.DesiredSize.Width, ActualHeight)); diff --git a/src/Shared/HandyControl_Shared/Controls/TabControl/TabPanel.cs b/src/Shared/HandyControl_Shared/Controls/TabControl/TabPanel.cs index ec7c5bd5..f1c26ace 100644 --- a/src/Shared/HandyControl_Shared/Controls/TabControl/TabPanel.cs +++ b/src/Shared/HandyControl_Shared/Controls/TabControl/TabPanel.cs @@ -22,11 +22,15 @@ namespace HandyControl.Controls /// internal Dictionary ItemDic = new Dictionary(); + public static readonly DependencyPropertyKey FluidMoveDurationPropertyKey = + DependencyProperty.RegisterReadOnly("FluidMoveDuration", typeof(Duration), typeof(TabPanel), + new PropertyMetadata(new Duration(TimeSpan.FromMilliseconds(0)))); + /// /// 流式行为持续时间 /// - public static readonly DependencyProperty FluidMoveDurationProperty = DependencyProperty.Register( - "FluidMoveDuration", typeof(Duration), typeof(TabPanel), new PropertyMetadata(new Duration(TimeSpan.FromMilliseconds(200)))); + public static readonly DependencyProperty FluidMoveDurationProperty = + FluidMoveDurationPropertyKey.DependencyProperty; /// /// 流式行为持续时间 @@ -96,7 +100,7 @@ namespace HandyControl.Controls protected override Size MeasureOverride(Size constraint) { - if ((_itemCount == InternalChildren.Count || !CanUpdate) && !ForceUpdate) return _oldSize; + if ((_itemCount == InternalChildren.Count || !CanUpdate) && !ForceUpdate && !IsTabFillEnabled) return _oldSize; constraint.Height = TabItemHeight; _itemCount = InternalChildren.Count;