I divided the main window in 3 parts, the left and the right part allow the user to either select private message or public channel which get displayed on the middle panel. My problem is that the buttons on the sides that allow to display the correct UserControl are a child of a child of a child and I don't know how to modify the ContentControl of the MainWindow from this many children.
Inside of my MainWindow I have a ContentControl that display the correct Control (ChatViewModel is a UserControl, I am just to lazy to rename it)
<ContentControl Grid.Row="1" Grid.Column="1" DataContext="{Binding Selection}" x:Name="MainPanel">
<ContentControl.Resources>
<DataTemplate DataType="{x:Type chat:UserMessages}">
<chat:ChatViewModel DataContext="{Binding Selection}"/>
</DataTemplate>
<DataTemplate DataType="{x:Type channel:ChannelClass}">
<channel:PrintChannel DataContext="{Binding Selection}"/>
</DataTemplate>
</ContentControl.Resources>
</ContentControl>
Selection is a variable that I declare in the C# code of the MainWindow. I looked at dependency properties and other stuff but I can't make anything work. Even if the answer is not pretty, I need this to work!