Fixed a bug of tabcontrol

This commit is contained in:
NaBian committed 2018-09-11 15:17:51 +08:00
1 parent be950fac36
commit 4cd13e84b2
3 files changed
+10 -7

No files matched your search

@@ -133,7 +133,7 @@ namespace HandyControl.Controls
if (!IsEnableTabFill)
{
_itemShowCount = (int)(ActualWidth / TabItemWidth);
_buttonOverflow.Show(Items.Count >= _itemShowCount);
_buttonOverflow.Show(Items.Count > 0 && Items.Count >= _itemShowCount);
}
if (IsInternalAction)
@@ -151,9 +151,10 @@ namespace HandyControl.Controls
}
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (UIElement item in e.NewItems)
foreach (TabItem item in e.NewItems)
{
item.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
item.IsSelected = true;
}
}
IsInternalAction = false;
@@ -170,7 +171,7 @@ namespace HandyControl.Controls
if (_buttonOverflow != null)
{
_itemShowCount = (int)(ActualWidth / TabItemWidth);
_buttonOverflow.Show(Items.Count >= _itemShowCount);
_buttonOverflow.Show(Items.Count > 0 && Items.Count >= _itemShowCount);
var menu = new ContextMenu
{
+5 -3
View File
@@ -107,7 +107,7 @@ namespace HandyControl.Controls
var count = InternalChildren.Count;
if (count == 0)
{
_oldSize.Width = 0;
_oldSize = new Size();
return _oldSize;
}
constraint.Width += InternalChildren.Count;
@@ -121,7 +121,10 @@ namespace HandyControl.Controls
}
else
{
arr = ArithmeticHelper.DivideInt2Arr((int)constraint.Width, count);
if (TemplatedParent is TabControl tabControl)
{
arr = ArithmeticHelper.DivideInt2Arr((int)tabControl.ActualWidth + InternalChildren.Count, count);
}
}
for (var index = 0; index < count; index++)
@@ -140,7 +143,6 @@ namespace HandyControl.Controls
Width = itemWidth,
Height = TabItemHeight
};
Console.WriteLine(rect);
tabItem.Arrange(rect);
tabItem.ItemWidth = itemWidth - tabItem.BorderThickness.Left;
tabItem.CurrentIndex = index;
+1 -1
View File
@@ -81,7 +81,7 @@
<RowDefinition x:Name="RowDefinition1" Height="*"/>
</Grid.RowDefinitions>
<Border Background="White" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource BorderBrush}">
<controls:TabPanel TabItemHeight="{TemplateBinding TabItemHeight}" TabItemWidth="{TemplateBinding TabItemWidth}" IsEnableTabFill="{TemplateBinding IsEnableTabFill}" Margin="0,0,-1,-1" x:Name="PART_HeaderPanel" HorizontalAlignment="Left" Background="{DynamicResource SecondaryTextBrush}" IsItemsHost="true" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1">
<controls:TabPanel MinHeight="{TemplateBinding TabItemHeight}" TabItemHeight="{TemplateBinding TabItemHeight}" TabItemWidth="{TemplateBinding TabItemWidth}" IsEnableTabFill="{TemplateBinding IsEnableTabFill}" Margin="0,0,-1,-1" x:Name="PART_HeaderPanel" HorizontalAlignment="Left" Background="{DynamicResource SecondaryTextBrush}" IsItemsHost="true" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1">
<interactivity:Interaction.Behaviors>
<interactivity:FluidMoveBehavior AppliesTo="Children" Duration="{Binding FluidMoveDuration,ElementName=PART_HeaderPanel}">
<interactivity:FluidMoveBehavior.EaseX>