I have some code that works in winforms, but not in WPF apparently, the code is as follows: This is set globally:
Private Property avar As Object Public main As MainWindow Public charchoice As Char
And then in the Window Loaded sub, this is placed:
charchoice = main.charchoice
Thing is, the next window doesn't pick up this variable, so how can I make it recognise and use it? Thanks Guys
I had a similar problem and discovered that you must create a public property in the MainWindow and pass a value to the property.
Please see this <a href="https://stackoverflow.com/questions/6427080/change-a-textboxs-text-value-on-a-usercontrol-from-a-window-in-wpf" rel="nofollow">example</a> from a similar question I posted.Answer2:
Hey i got same problem when i am going to pass values between two forms. I find its solution using a simple class and Shared property.
First I create a class named with cls_pass_val which is as under:-
Public Class cls_pass_val Private Shared var_pass_val As String = "" Public Shared Property Pass_val() As Char Get Return var_pass_val End Get Set(ByVal value As String) var_pass_val = value End Set End Property End Class
Now at the time of assigning a value:<br />
and at the time of retrieving the value:
Dim var_c as Char var_c=cls_pass_val.Pass_val