@Aswin
I've added a new answer, as I can format it properly
OK. A simple way to do this is to create a model for the password page, typically it would have a property
Username
and
Password
, Lets call the type
LoginCredentials
, it would implement INotifyPropertyChanged. You then set the
DataContext
of the Login
Window to a new
LoginCredentials
object in you can do this in "code-behind". You then bind the Text Properties of the Username and Password boxes to the equivalent properties in your
DataContext
.
See here for an article on Data Binding:
Moving Toward WPF Data Binding One Step at a Time[
^], just look at
"Version 4 – Binding in XAML"
I wasn't clear about "Interrogate the object at all", sorry, I was pretty tired when I replied, so my bad. The Main winow will have access to it's child Login Windows
DataContext
You can cast this to
LoginCredentials
and access the Username and Password properties you added.
Finally I'd add this: IMO, all the windows should have their own object model controlling behaviour, and have properties bound up in XAML. The code-behind is really just to support the events, etc. The models can be built up so that the main page model has a login credentials property. One caveat if you do this is that the password will be available in memory, so you should do something about this. I'd just keep the username in the Login model, store the password until the user logs in (the login model should be responsible for this), then keep a bool logged in status or some-such. That way you get good separation of concerns, and the code actually becomes clearer.
Hope this [rather long-winded] reply helps!