Pages Navigation
<Button Content="Navigate to Page 2" HorizontalAlignment="Left" Margin="126,54,0,0" Grid.Row="1" VerticalAlignment="Top" Height="69" Width="268"/>
<TextBlock x:Name="txtpage1block" HorizontalAlignment="Left" Margin="126,160,0,0" Grid.Row="1" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="59" Width="556"/>
//Page Navigation
private void Button_Click_1(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(BasicPage2));
}
It will show the navigation between Page 1 and Page 2.
Passing Parameter
private void Button_Click_1(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(BasicPage2),"Test Parameters");
}
Now go to the Page 2 code behind and write the below code in the OnNavigatedTo event which gets the parameter value that is passed and use it across in the page as required:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string strValue= e.Parameter as string;
if(!string.IsNullOrWhiteSpace(strValue))
{
txtpage2block.Text="This is the value passed, " + strValue;
}
else
{
txtpage2block.Text="No Value passes!!!":
}
}
Now you can see the value "Test Parameters" is passed and assigned to the Txtpage2block in Page2.