How can I get a text from a textbox and display it in a label of another C # WPF? [closed]

1

I have the doubt of how to put the text that is entered in a textbox in another window.

Explaining this:

The user will login in a window, at the time of entering a splash will open welcoming, what I want to do is to appear the username you entered in the splash welcoming.

My code is as follows:

Login window

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void BtnIngreso_Click(object sender, RoutedEventArgs e)
    {

        //Validacion de usuario y contraseña
            if (txtuser.Text == "User" && txtpass.Password == "1234")
            {
                //Si el usuario es correcto, llamar al splash
                SplashBienvenida splashBienvenida = new SplashBienvenida();
                splashBienvenida.LUser = txtuser;
                splashBienvenida.Activate();
                splashBienvenida.Show();
                this.Close();
            }
            else
            {
                //Mostrar el mensaje en caso erróneo 
                MessageBox.Show("Usuario o contraseña no validos");
            }

    }

Splash Window

public partial class SplashBienvenida : Window
{
    DispatcherTimer dT = new DispatcherTimer();

    public SplashBienvenida()
    {

        InitializeComponent();
        //Inicia el conteo que durara la ventana de Bienvenida
        dT.Tick += new EventHandler(dT_Tick);
        dT.Interval = new TimeSpan(0,0,10);
        dT.Start();


    }
    //Al momento que termine el conteo mandara llamar la ventana siguiente
    public void dT_Tick(object sender, EventArgs e)
    {

        Opciones opciones = new Opciones();
        opciones.Show();

        dT.Stop();
        this.Close();
    }

}
    
asked by Gabriel Garza 25.10.2018 в 17:48
source

1 answer

0

I think the problem is that you are assigning the TextBox reference to the Label, when in reality you should assign the value contained in the control.

That is, you should change this:

splashBienvenida.LUser = txtuser;

Because of this:

splashBienvenida.LUser.Content = txtuser.Text;

Good luck!

    
answered by 28.10.2018 / 23:24
source