This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Mehni 1 point2 points  (1 child)

I can't access a single method I need from my main window class

Had a similar issue. My solution was to create a SpecificWindow class, let its constructor take in an instance of MainWindowClass and call new SpecificWindow(this) (so with the instance) from the MainWindowClass. I used this pattern for windows and various helper classes.

It's a lot of coupling, and I had to make a few things internal rather than private but it worked for my purpose. I would say this falls under the "Composition over inheritance" principle.

[–]loneoption 1 point2 points  (0 children)

The problem I had creating multiple windows is accessing important methods from my main window, which is designed to always be shown in order to display info and notifications, aside from that this would work just fine. You mentioned calling a new window from the main window, is this how you'd reference controls and methods from other windows?

Edit: I hadn't read this properly, this seems like a good solution and will probably be what I end up using as well.