From 4564e7efbf39211a30aac00278326f4df40783ea Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Sat, 18 Mar 2023 15:07:10 +0800
Subject: [PATCH] fix: close #1367
---
.../Controls/TabControlDemoCtl.xaml | 2 +-
.../Controls/TabControl/TabControl.cs | 25 ++++++++++++++++---
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml
index 78c93a18..79d5966e 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml
@@ -66,7 +66,7 @@
-
+
diff --git a/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs b/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs
index 909e8aa2..3377021f 100644
--- a/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs
+++ b/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs
@@ -219,6 +219,15 @@ public class TabControl : System.Windows.Controls.TabControl
set => SetValue(ShowScrollButtonProperty, ValueBoxes.BooleanBox(value));
}
+ public static readonly DependencyProperty OverflowMenuDisplayMemberPathProperty = DependencyProperty.Register(
+ nameof(OverflowMenuDisplayMemberPath), typeof(string), typeof(TabControl), new PropertyMetadata(default(string)));
+
+ public string OverflowMenuDisplayMemberPath
+ {
+ get => (string) GetValue(OverflowMenuDisplayMemberPathProperty);
+ set => SetValue(OverflowMenuDisplayMemberPathProperty, value);
+ }
+
///
/// 可见的标签数量
///
@@ -346,10 +355,20 @@ public class TabControl : System.Windows.Controls.TabControl
if (item.DataContext is not null)
{
- menuItem.SetBinding(HeaderedItemsControl.HeaderProperty, new Binding(DisplayMemberPath)
+ if (ItemTemplate is null)
{
- Source = item.DataContext
- });
+ menuItem.SetBinding(HeaderedItemsControl.HeaderProperty, new Binding(DisplayMemberPath)
+ {
+ Source = item.DataContext
+ });
+ }
+ else
+ {
+ menuItem.SetBinding(HeaderedItemsControl.HeaderProperty, new Binding(OverflowMenuDisplayMemberPath)
+ {
+ Source = item.DataContext
+ });
+ }
}
else
{