Multi-page silverlight app
I'm following a small tutorial on how to switch pages in Silverlight. It can be found here:
http://jesseliberty.com/2008/05/31/multi-page-applications-in-silverlight/
It's slightly older, but everything worked.The technique used here is to ha开发者_如何学Pythonve a seperate page with a "Navigator function". If you're on Page1, you use something like this:
PageSwitcher ps = this.Parent as PageSwitcher;
ps.Navigate(new Page2());
With Navigate being the only function in PageSwitcher:
public void Navigate(UserControl nextPage) {
this.Content = nextPage;
}
Still, the way this is handled seems kind of odd. I'm still wondering what the difference is between adding a new User Control and Page. I've tried adding them both, they very much seem the same.
It seems like this is just using a hidden page to engineer the switching between the public pages. This seems somehow over the top to me. Is there an other way?
I think the difference between Page and UserControl is that Page has some Navigation methods like NavigationService.
For another way, check out Caliburn Micro's Screens and Conductors. It lets you do some advanced navigation stuff with little effort, check out the sample, HelloScreens. It adds life-cycle to your Screens. Also the ability to know when the view's been bound and nice stuff like that.
精彩评论