In my project I have fixed header & footer, and changeable content. so i have put ContentControl in my window.
<Grid>
<Canvas Name="canvas_Logo" HorizontalAlignment="Center" VerticalAlignment="Top" Width="180">
<Image Source="Images/k1.png" Grid.Row="1" Width="180" />
</Canvas>
<ContentControl VerticalAlignment="Center" Name="CC1" Grid.Row="2" Height="450"/>
<Canvas x:Name="canvas_Marque" ClipToBounds="True" Height="60" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="1022" Background="DarkRed" />
</Grid>
It look like this...
I have create two user control name page1, page2. Page 1 has a button, when i click the button ContentControl has show page2.
so i have write the below code in button1_Click
MainPage n = new MainPage();
n.CC1.Content = new Page2();
But at the time of button click ContentControl not changed what can i do for that?
My page1 xaml
<Grid Background="AliceBlue">
<Label Content="Child1" Height="28" HorizontalAlignment="Left" Margin="74,65,0,0" Name="label1" VerticalAlignment="Top" Width="157" />
<Button Content="load page2 and destroy this" Height="31" HorizontalAlignment="Left" Margin="79,124,0,0" Name="button1" VerticalAlignment="Top" Width="186" Click="button1_Click" />
</Grid>
page2 xaml
<Grid Background="CadetBlue">
<Label Content="This is page 2" Height="28" HorizontalAlignment="Left" Margin="96,82,0,0" Name="label1" VerticalAlignment="Top" Width="148" />
</Grid>
How to change the content control Content in WPF?