提交 4564e7ef 编写于 作者: N NaBian

fix: close #1367

上级 e932327a
......@@ -66,7 +66,7 @@
<hc:SimplePanel Background="#FFE8E03F"/>
</hc:TabItem>
</hc:TabControl>
<hc:TabControl Grid.Row="2" IsAnimationEnabled="True" Margin="0,32,0,0" ShowCloseButton="True" IsDraggable="True" ItemsSource="{Binding DataList}" MaxWidth="800" Height="300">
<hc:TabControl Grid.Row="2" IsAnimationEnabled="True" Margin="0,32,0,0" ShowCloseButton="True" IsDraggable="True" ItemsSource="{Binding DataList}" MaxWidth="800" Height="300" OverflowMenuDisplayMemberPath="Header">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Header}"/>
......
......@@ -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);
}
/// <summary>
/// 可见的标签数量
/// </summary>
......@@ -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
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册