Silverlight中的页面跳转

方案:

1.在App.xaml.cs中定义一个Grid控件:

    Grid grid=new Grid();

2.当整个应用程序启动运行时,让它第一个页面Login页面在Application Startup事件中来处理解决

   private void Application_Startup(object sender,StartupEventArgs e)

  {

     this.RootVisual=rootGrid;

     this.rootGrid.Children.Add(new Login());

   }

3.登录成功后我们还在App.xaml.cs里面写一个方法来解决

     public void Turn(UserControl userControl)

   {

        App app=App.Current as App;

         app.rootGrid.Children.Clear();

         app.rootGrid.Children.Add(userControl);

    }

4.在Login.xaml.cs中的Button事件中添加这样的代码:

    App app=App.Current as App;

    Content content=new Content();//新页面

    content.lblUserName.Text=txtUerName.Text.Trim();

    content.lblPwd.Text=txtPwd.Text.Trim();

    app.Turn(content);

posted @ 2011-04-01 14:56  xuebingz  阅读(371)  评论(0)    收藏  举报