HandyControl
HandyControl copied to clipboard
[Feature request] Add "new tab" button to <hc:TabControl>
Is your feature request related to a problem? Please describe.
In our application we use the <hc:TabControl>
control to let the user have different workspaces and perform different tasks in parallel like tabs in a web browser. We have a "+ New tab"
button ("Nueva pestaña" in spanish) and when the user clicks the button a new tab is added to the ViewModel.
It would be nice to have a way to add an extra button in the tab strip like in Google Chrome, to let the user add a new tab.
This is our current setup (in case it matters)
<hc:TabControl
TabStripPlacement="Bottom"
Grid.Column="1"
TabIndex="-1"
KeyboardNavigation.TabNavigation="None"
x:Name="tabControl"
ShowCloseButton="True"
ShowOverflowButton="True"
ShowScrollButton="True"
IsDraggable="True"
IsScrollable="True"
IsAnimationEnabled="True"
IsTabFillEnabled="False"
Validation.ErrorTemplate="{x:Null}"
ItemsSource="{Binding Workspaces}"
SelectedItem="{Binding SelectedWorkspace}">
<hc:TabControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" MaxWidth="200">
<fa:IconBlock Icon="{Binding Page.Icon, FallbackValue=None}" FontSize="12" IconFont="Solid" Margin="0,0,8,0"/>
<TextBlock Text="{Binding Page.Title}"/>
</StackPanel>
</DataTemplate>
</hc:TabControl.ItemTemplate>
<hc:TabControl.ContentTemplate>
<DataTemplate>
<ContentControl Content="{Binding Page}" Validation.ErrorTemplate="{x:Null}"/>
</DataTemplate>
</hc:TabControl.ContentTemplate>
</hc:TabControl>
Describe the solution you'd like
An easy solution would be to add a <hc:TabControl.ExtraToolsTemplate>
that can be customized via xaml. In this way would add our custom button to the end of the TabControl
, and user who don't want that functionality would be unafected.
Something like this:
<hc:TabControl ItemsSource="{Binding Workspaces}" SelectedItem="{Binding SelectedWorkspace}">
<hc:TabControl.ExtraToolsTemplate>
<DataTemplate>
<Button Width="32" Command="{Binding AddWorkspaceCommand}">
<fa:IconBlock Icon="Plus"/>
</Button>
</Button >
</hc:TabControl.ExtraToolsTemplate>
</hc:TabControl>
This way developers will be able to add extra tools like "Add Foo tab", "Sort tabs" or other domain specific tools in the same DataTemplate
.
Describe alternatives you've considered Currently I use a separate button at the top bar, but is not intuitive and unconventional.
Additional context Add any other context or screenshots about the feature request here.