There is no such concept as "global variable" in .NET. Not at all. And this is very good. The practice of using of such variable is bad.
There are static class members, which have a lot in common with "global variables", because they are stored "globally", per class (not per instance), even though they are the subject of access modification described in a class. They are also should be used with care; and usually you can avoid using them. One obvious problem is that they create separate additional shared resources which needs synchronization when multithreading is used.
The solution? The really robust approach is using the
instance members, not static. When beginners say "different windows", they tend to forget to explain: different classes or instances? The essence of this problem is in the instances. The simplest solution is: you can create an instance property of your window classes, of a reference type, which should keep the reference to the same object (say, with user credentials, as in your case). You can create first object in, say, main window, which plays the role of a
singleton. It depends; it can be anywhere. Other windows can get the reference to the same object as you create them. Anyway, you keep the points where you create any additional window under your control, so you can always set a reference.
For the related topic
singleton (which also should be used with care and is best avoided), please see:
Singleton pattern — Wikipedia, the free encyclopedia[
^],
C# in Depth: Implementing the Singleton Pattern[
^].
See also my Tip & Tricks article which is not directly related to your issue, but deals with the inquirers' issue which has a lot in common with yours:
Many Questions Answered at Once — Collaboration between Windows Forms or WPF Windows[
^].
—SA