Heys, I currently have a set up that allows me to add and remove new tabs, the only problem is I have problem adding anything to this new tab. I want to have a text box in there but am having troubling adding one, the tabs are just appearing as blank. Any help would be great, thank you!
Here is how I have it setup:
The button that makes a new tab:
<Button
FontSize="12"
Content="Private Chat"
Grid.Column="1" Height="23" HorizontalAlignment="Left" Margin="147,118,0,0" VerticalAlignment="Top" Width="75"
Name="btnPrivateChat" Click="btnPrivateChat_Click" />
Which calls this function:
private void btnPrivateChat_Click(object sender, RoutedEventArgs e)
{
ListBoxItem userName = lstOnlineUsers.SelectedItem as ListBoxItem;
if (userName != null)
{
TabHandler newTabItem = new TabHandler();
newTabItem.Title = userName.Content.ToString();
;
ChatTabControl.Items.Add(newTabItem);
newTabItem.Focus();
newTabItem.ApplyTemplate();
}
else
{
MessageBox.Show("Error! Please select a username.");
}
}
Which then creates an instance of the usercontrol TabHandler:
public TabHandler()
{
TabHeader tabHeader = new TabHeader();
Usercontrol TabHandler (XAML) :
<usercontrol x:class="TrapezoidTabs.TabHeader" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="23" d:DesignWidth="81" Margin="0">
<grid>
<Button Content="X" Height="19" HorizontalAlignment="Right" Margin="0,3,4,0" Name="btnCloseTab" VerticalAlignment="Top" Width="20" FontFamily="Courier" FontWeight="Bold" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" FontStretch="Normal" Visibility="Visible" FontSize="14" Padding="0" ToolTip="Close"/>
<Label FontSize="14" Foreground="Black" Content="User" Height="23" HorizontalAlignment="Left" Margin="4,1,0,0" Name="lblTabTitle" VerticalAlignment="Top" />
</grid>
</usercontrol>
Should I be making a new Window instead of a usercontrol? I realy want to add content to each page. Thanks in advance!