c# - DataBinding Between 2 WPF Windows with 2 TextBoxes -
I have the following problem, I do not know why my databunding does not work (I already did it in my program In the same way and it works). It may be that this does not work, I pass the main window and go to window 2, but only my reference set on window 2 for the main-window. Still do not know how to solve it My code (forgot to cut it, I hope I can not forget anything, because 600 or 700 rows have more than 600 codes)
< Code> private zeros btLogin_Click (object sender, RoutedEventArgs e) {var window 2 = new window2 (); Login USERTB = new login (); // References to access login references and check whether we can read the logged-in user from Window.Show (); USERTB.Username = tbLoginUser.Text; // Check whether it knows the username - so far it is working. Hide (); After this, the problem begins, the values of my textbox do not go to the other from the main window, even if I try to get it with reference to USER. Here Window 2. XML & amp; Window2.cs:Window 2 cc:
string action; Get public string action {get; This.action; } Set {this.action = value; OnPropertyChanged ("Action"); }} Private Zero SmthHappens (Object Sender, DependencyPropertyChangedEventArgs e) {var felh = new MainWindow (); Action = Fail. USER; // Here is the TB value of MW, so here is the problem TBShow Text = action; }
I try to pass the MW of Tb value to W2 tbShow. I think my code is wrong in Muthheyapense, Cause I have already passed MW and this TBOGIN has lost the value of the user. But I do not know how to solve it. Please help!
Solved! Thanks for the reply, I solved it in the same way, as I tried to do this, maybe I'll check MVVM a little later, but now I do not have much left over my program, so I finish it :) In these cases, generally the MVVM pattern used in WPF comes in handy. Create a square, which contains the property, which You want to share, and you can pass it through a visual model in two forms.
More, read on the MVVM design pattern used in WPF.
Comments
Post a Comment