Id start with Creating a TabControl in WPF,
<TabControl Height="500" Width="Auto" FontSize="14" Name="Mytabcontrol"> </TabControl>
Then in your c# code add something like:
private void AddTabitem()
{
TabItem ti = new TabItem();
ti.Header = "Tab";
ti.Content = // Your richtextbox;
Mytabcontrol.Items.Insert(Mytabcontrol.Items.Count, ti);
Mytabcontrol.SelectedIndex = Mytabcontrol.Items.Count - 1;
And then a SelectionChanged Event
Mytabcontrol.SelectionChanged += new SelectionChangedEventHandler(TabSelectionChanged);
}
This code might also get in handy:
void TabSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (Mytabcontrol.SelectedItem != null)
{
TabItem ti= Mytabcontrol.SelectedItem as TabItem; // Selected Tab
if (tabitem.Content != null)
{
RichTextBox txt = ti.Content as RichTextBox; // your textbox
}
}
}