You have two options.
Using the navigation framework or manually adding the controls to the main window. Basically, I would do the latter. To do this you need to create a main window or user control. In this you add a content control. You would then in code, add other user controls to the content control.
This is a very basic and high overview. Please see some links below that will help.
thanks
WPF-A-Beginner-s-Guide-Part-1-of-n[
^]
Without blowing your mind too much, I recommend you start to understand MVVM with WPF. I would also recommend using a framework that handles many of the boiler plate or comlex code that you end up writing.
Here are some recommended links:
http://cinch.codeplex.com[
^]
http://compositewpf.codeplex.com/[
^]
I use the Prism framework. I big learning curve, but the sample downloads and the accompanying documentation are really good.
Finally I would also recommend
In the Box – MVVM Training[
^]
UPDATE:
Ok, Add 3 wpf usercontrols to your solution called view1,view2 and view3.
Next try:
<Window x:Class="TestWPFApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Width="800"
Height="600">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Margin="10"
BorderBrush="BlueViolet"
BorderThickness="2"
CornerRadius="8">
<StackPanel Orientation="Vertical">
<Button Name="Btn1" Margin="10" Tag="1" Click="MenuBtn_OnClick">View 1</Button>
<Button Name="Btn2" Margin="10" Tag="2" Click="MenuBtn_OnClick">View 2</Button>
<Button Name="Btn3" Margin="10" Tag="3" Click="MenuBtn_OnClick">View 2</Button>
</StackPanel>
</Border>
<Border Grid.Column="1"
Margin="10"
BorderBrush="Chartreuse"
BorderThickness="2"
CornerRadius="8">
<ContentControl Name="CcMainContent" />
</Border>
</Grid>
</Window>
then in code behind something like:
namespace TestWPFApplication
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Loaded += (s, e) => LoadView(1);
}
public void LoadView(int viewId)
{
switch (viewId)
{
case 1:
CcMainContent.Content = new View1();
break;
case 2:
CcMainContent.Content = new View2();
break;
case 3:
CcMainContent.Content = new View3();
break;
}
}
private void MenuBtn_OnClick(object sender, RoutedEventArgs e)
{
Button menuButton = sender as Button;
if (menuButton != null)
{
LoadView(Convert.ToInt32(menuButton.Tag));
}
}
}
}
UPDATE 2: AND IN VB!
Namespace TestWPFApplication
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
AddHandler Loaded, AddressOf MainWindow_Loaded
End Sub
Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs)
LoadView(1)
End Sub
Public Sub LoadView(viewId As Integer)
Select Case viewId
Case 1
CcMainContent.Content = New View1()
Case 2
CcMainContent.Content = New View2()
Case 3
CcMainContent.Content = New View3()
End Select
End Sub
Private Sub MenuBtn_OnClick(sender As Object, e As RoutedEventArgs)
Dim menuButton As Button = TryCast(sender, Button)
If menuButton IsNot Nothing Then
LoadView(Convert.ToInt32(menuButton.Tag))
End If
End Sub
End Class
End Namespace