How do I load a new Page?
i have multiple Pages (cla开发者_C百科sses which derive from the Page object) in my silverlight app. I can load one in the app.xml with this statement: this.RootVisual = new ZoomData ();
But what should i do when i have this page loaded, and i want to navigate to another page?
Look into creating your app using the "Silverlight Navigation Application" template.
This provides the basic framework to create multi-page silverlight applications.
i ended up with this:
In the application_startup
Grid root = new Grid();
this.RootVisual = root;
root.Children.Add(new ZoomData()); // This is your first page
in the click event of a button
Grid root = Application.Current.RootVisual as Grid;
root.Children.RemoveAt(0);
root.Children.Add(new ZoomData());
精彩评论