Skip to content

Commit

Permalink
fix: close #1367
Browse files Browse the repository at this point in the history
  • Loading branch information
NaBian committed Mar 18, 2023
1 parent e932327 commit 4564e7e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}"/>
Expand Down
25 changes: 22 additions & 3 deletions src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ public bool ShowScrollButton
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>
Expand Down Expand Up @@ -346,10 +355,20 @@ private void ButtonOverflow_Click(object sender, RoutedEventArgs e)

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
{
Expand Down

0 comments on commit 4564e7e

Please sign in to comment.