Tutorials » Silverlight tutorials »

How to open XAML pages from another XAML page ?

This chapter shows how to open a xaml page from another xaml page.

In a Silverlight application, you can have multiple XAML pages. When you use the .xap file in the web page, only one XAML control will be displayed at a time. The default XAML file displayed is determined by the following code in the App.xaml file:

this.RootVisual = new Page1();

You can change the above line to the class name of any oher xaml file to open that file by default.

Another scenario is, you may want to open different xaml files from the default xaml page. For example, consider that you have a xaml control that prompt user to enter login information. After the login credentials are validated, you may want to redirect to another xaml file when the user click the "Submit" button.

This can be done by setting the "Content" property of the xaml page.

private void SubmitButton_Click(object sender, RoutedEventArgs e)
this.Content = new NewXamlPage();

The above code shows how to set the "Content" property of the xaml control in the button click event handler. When the user click on the submit button, the new xaml file (NewXamlpage) will be opened and original xaml file will be recycled.

Next Chapter: Open a specific xaml page from a Silverlight control
Previous Chapter: How to set default .xaml page in a Silverlight control ?
More Chapters: Silverlight Tutorials
More Tutorials: Tutorial Index

Top Contributors
TodayLast 7 Daysmore...

Awards & Gifts

Online Members

Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India