Im strongly recommend you to use an existing library bevor starting to create your own infrastructure. (I've learnd it the hard way and ended up using prism ;) ) There are other great libraries out there, too. Just go to youtube and search for "c# prism outlook" there is a pretty good prism tutorial from brian lagunas.
Edit:
Just to give you an basic idea how you can solve this by yourself:
Main Window xaml:
<Window x:Class="WpfTestApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfTestApp"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0" x:Name="Ribbon"/>
<ContentPresenter Grid.Row="1" x:Name="Content"/>
<StackPanel Grid.Row="2">
<Button Grid.Row="0" Content="SetContentFormA" Click="Button_Click"/>
<Button Grid.Row="0" Content="SetContentFormB" Click="Button_Click_1"/>
<Button Grid.Row="0" Content="AddNewFormAToRibbon" Click="Button_Click_2"/>
<Button Grid.Row="0" Content="RemoveFormBFromRibbon" Click="Button_Click_3"/>
</StackPanel>
</Grid>
MainWindow.cs:
public partial class MainWindow : Window
{
private FormB b;
public MainWindow()
{
InitializeComponent();
PageControler.Content = Content;
PageControler.Ribbon = Ribbon;
b = new FormB();
Ribbon.Children.Add(b);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
PageControler.SetContent(new FormA());
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
PageControler.SetContent(new FormB());
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
PageControler.AddToRibbon(new FormA());
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
PageControler.RemoveFromRibbon(b);
}
}
PageControler:
public static class PageControler
{
public static ContentPresenter Content { get; set; }
public static WrapPanel Ribbon { get; set; }
public static void SetContent(UserControl control)
{
Content.Content = control;
}
public static void AddToRibbon(UserControl control)
{
Ribbon.Children.Add(control);
}
public static void RemoveFromRibbon(UserControl control)
{
Ribbon.Children.Remove(control);
}
}
FormA (& B):
<UserControl x:Class="WpfTestApp.FormA"
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"
xmlns:local="clr-namespace:WpfTestApp"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid Background="Violet">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="Form A"/>
</Grid>
You can althou