none
How to pass a class between windows in wpf? RRS feed

  • Pergunta

  • Hi!

    I am trying to develop an application in WPF. It has several windows

    namespace WpfApplication
    {

     public class allthedata
     {
      public string name { get; set; }
      public int id { get; set; }
      public string password { get; set; }
      public image photo { get; set; }
      public string obs { get; set; }
      ....
     }

    }

     

    -//-

     

    namespace WpfApplication
    {


     public partial class MainWindow: Window
     {

             public MainWindow ()
             {
                  InitializeComponent ();
                  / / Insert code required on object creation below this point.
             }
     
             private void LoginUser_Click (object sender, RoutedEventArgs e)
             {
                   Window2 wb = new Window2();
       userallinfo info = new userallinfo();
     
                  allthedata allthedata name = new ();
        
       ....

                      if (result)
                     {
        
        info.name = name.text;
        info.password = pwd.password;
        ....

                          / / Close this window
                          this.Close ();
                          wb.ShowDialog ();
                     }
             }
     }

    ...

    }


    I do not know how to pass data and class allthedata between them (the real program as about 7 windows that open and close).

    After logging the mainwindow close and open a second window. The data of the mainwindow (login, password and id of user is in a class userallinfo).
    The user after answering some questions in this window closet and may open other windows without losing the data from the main and this window.
    As you go from window to window the data already accumulated is not lost and can be changed at any time.
    How can i do this?


    John PT
    segunda-feira, 9 de agosto de 2010 22:44

Respostas

Todas as Respostas