OK try this
Define the ControlTemplate of the TabControl like this:
<!-- Sets the look of the Tabcontrol. -->
<Style x:Key="TabControlStyle" TargetType="{x:Type TabControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid>
<!-- Upperrow holds the tabs themselves and lower the content of the tab -->
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
The upper row in the grid would be the TabPanel but you would put that into a StackPanel with a button following the TabPanel, style the button to look like a tab
Now the button would create a new TabItem (your custom created one perhaps) and add it to the ObservableCollection of Tabs you have as the Itemssource for your TabControl.
1) I think I know what you mean but not sure though, update me on this one
2 & 3) It should always appear at the end, and it's not a tab so hopefully not part of tab cycling
4) Well your TabControl should use a ObservableCollection of TabItems as Itemssource to be notified when a new one is added/removed
Hope this helps.
EDIT: Adding some code
The NewTabButton usercontrol .cs file
public partial class NewTabButton : TabItem
{
public NewTabButton()
{
InitializeComponent();
Header = "+";
}
}
and the main window:
public partial class Window1 : Window
{
public ObservableCollection<TabItem> Tabs { get; set; }
public Window1()
{
InitializeComponent();
Tabs = new ObservableCollection<TabItem>();
for (int i = 0; i < 20; i++)
{
TabItem tab = new TabItem();
tab.Header = "TabNumber" + i.ToString();
Tabs.Add(tab);
}
Tabs.Add(new NewTabButton());
theTabs.ItemsSource = Tabs;
}
}
Now we would need to find a way to let it always appear bottme right and also add the event and style for it ( the plus sing is there as a placeholder ).
I'll take a better look tomorrow.