1

Is it possible to access App instance from MainWindow instance?

My App performs some initialization steps (like configuration initialization) and I need to pass the config to MainWindow.

1 Answer 1

2

App.Current should return this instance, you will need to cast it though.

Sign up to request clarification or add additional context in comments.

5 Comments

Oh, thanks, cannot realize that I can cast it. Well, before I checked you (15 mins cap) - is it possible to access MainWindow from App? I bet it is not, but just to be sure ;-)
Yes you can, somewhat, but you need to make the MainWindow the actual main window of the application by using the Application.MainWindow property, otherwise you can try and find it in the Windows collection of the application for example by checking the types of the windows.
the issue is - in App.Init() method .MainWindow hasn't been initialized yet...
Then you need to work with calls from the window to the app i suppose.
yup, that is why I asked about Window -> App direction in initial question ;-) Thanks for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.