diff --git a/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml b/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
index 912da523..46d965bd 100644
--- a/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
+++ b/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
@@ -6470,7 +6470,7 @@
-
+
@@ -6602,7 +6602,7 @@
-
+
diff --git a/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs b/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs
index 03986c13..b4813a2d 100644
--- a/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs
+++ b/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs
@@ -4,6 +4,7 @@ using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
+using System.Windows.Data;
using System.Windows.Input;
using HandyControl.Data;
using HandyControl.Tools.Extension;
@@ -308,8 +309,11 @@ public class TabControl : System.Windows.Controls.TabControl
{
if (!IsTabFillEnabled)
{
- _itemShowCount = (int) (ActualWidth / TabItemWidth);
- _buttonOverflow?.Show(ShowOverflowButton && Items.Count > 0 && Items.Count >= _itemShowCount);
+ double actualWidth = ActualWidth;
+ double tabItemWidth = TabItemWidth;
+
+ _itemShowCount = (int) (actualWidth / tabItemWidth);
+ _buttonOverflow?.Show(Items.Count > 0 && Items.Count * tabItemWidth >= actualWidth && ShowOverflowButton);
}
}
@@ -335,15 +339,26 @@ public class TabControl : System.Windows.Controls.TabControl
var menuItem = new MenuItem
{
HeaderStringFormat = ItemStringFormat,
- HeaderTemplate = ItemTemplate,
- HeaderTemplateSelector = ItemTemplateSelector,
- Header = item.Header,
- Width = TabItemWidth,
IsChecked = item.IsSelected,
IsCheckable = true,
IsEnabled = item.IsEnabled
};
+ if (item.DataContext is not null)
+ {
+ menuItem.SetBinding(HeaderedItemsControl.HeaderProperty, new Binding(DisplayMemberPath)
+ {
+ Source = item.DataContext
+ });
+ }
+ else
+ {
+ menuItem.SetBinding(HeaderedItemsControl.HeaderProperty, new Binding(HeaderedItemsControl.HeaderProperty.Name)
+ {
+ Source = item
+ });
+ }
+
menuItem.Click += delegate
{
_buttonOverflow.IsChecked = false;
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml
index 7c6c147d..d73cc7e1 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml
@@ -28,7 +28,7 @@
-
+
@@ -160,7 +160,7 @@
-
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Theme.xaml b/src/Shared/HandyControl_Shared/Themes/Theme.xaml
index e03b86f8..4c391eeb 100644
--- a/src/Shared/HandyControl_Shared/Themes/Theme.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Theme.xaml
@@ -6552,7 +6552,7 @@
-
+
@@ -6684,7 +6684,7 @@
-
+