C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...







How to set default .xaml page in a Silverlight control ?



This chapter demonstrates how to change the default .xaml page used in a Silverlight control



Each Silverlight project can have multiple .xaml files. However, only one .xaml file will be visible at a time.

When you create a Silverlight project in Visual Studio, it will create a .xaml file called "Page1.xaml" by default and this .xaml control will be displayed by default when you open the web page.

You can change the default .xaml page by setting the property "Application.RootVisual".

To try this, add a .xaml file called "Page2.xaml" in your silverlight project.

Now, open your App.xaml.cs file in the Silverlight project. Look at the Application_Startup event handler. There you can see the default .xaml page being set. To change the default .xaml page, you have to specify the name of the class used in the .xaml page and set it to the Application.RootVisual property as shown below:

private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new Page2();
}

After you change the value here, compile the application and run. When the web page is opened, you can see that the new .xaml control is displayed in the web page.

  • Next Chapter: How to open XAML pages from another XAML page ?

  • Previous Chapter: How to place a Silverlight control in a web page ?

  • Tutorial Index



  • dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use