Solution 2 : Implementing GoToScreen Using Silverlight 3.0

You have two xaml pages named Screen1 and Screen2. On Screen1, there is a button named GoToScreen2Button. On Screen2, there is a button named GoToScreen1Button. Clicking on the GoToScreen2Button brings you to Screen2, and clicking on the GoToScreen1Button brings you to Screen1.

You could set the RootVisual property of Silverlight Application class to Screen1 if you want to go to it. Unfortunately, you cannot set the value of the RootVisual property more than one time from code. You can implement GoToScreen using the same concept of ASP.NET Master and Content Pages:

1.       Create a master screen.

2.       Add a Grid control named ContentGrid to the master screen. The grid control will be used as a content placeholder.

3.       In the master screen XAML code behind, create a method named GoToScreen.

4.       In the event handler for the Startup event of Application class, set the value of the RootVisual property to an instance of master screen.

5.       In the event handlers for the Click events of the GoToScreen1Button and GoToScreen2Button, call the GoToScreen method.

 

Published Sunday, December 6, 2009 9:04 PM by StanleyGu

Comments

# re: Implementing GoToScreen Using Silverlight 3.0

Sunday, December 6, 2009 10:31 PM by findleyd

Shouldn't step  3 clear the grid's children before adding the contentScreen so that the instances don't just stack up on top of each other in the grid?

# re: Implementing GoToScreen Using Silverlight 3.0

Monday, December 7, 2009 2:15 AM by Joe Chung

Why not just use Silverlight navigation?