Data Binding between two TextBoxes in different windows

前端 未结 4 2075
傲寒
傲寒 2021-01-14 04:00

I have created a program that changes the name in a TextBox when check or unckeck a Checkbox. I want to replicate this Textbox in a different window. I thought with Data Min

4条回答
  •  一个人的身影
    2021-01-14 04:15

    Don't set the DataContext explicitly, or only via another Binding. Your

    does nothing helpful. DataContext will be inherited as long as it is not overwritten. Don't set it explicitly. It should be enought to set it once on both windows.

    Create your data object in your MainWindow

    Texto prueba = new Texto("Carlos");
    Window1 nueva = new Window1();
    nueva.DataContext = prueba;
    nueva.Show();
    

    and remove all the other DataContext assignments.

提交回复
热议问题