方案:

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);

相关文章:

  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-14
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2021-06-17
相关资源
相似解决方案