In my current program I have a main window and a secondary window that pops up when a button is pressed. If the secondary window is currently shown but doesn’t have focus the button will instead bring it to focus.
At this time I am creating a new instance of the secondary window as the main window loads and simply checking its status with SubWindow.IsDisposed and SubWindow.CanFocus
I have found that if I do not create a new instance at the beginning SubWindow.IsDisposed throws an exception. As long as I’d previously created an instance of SubWindow the check runs fine.
My question- The current version works fine but is there a better way of doing this? It is not a huge concern, but it feels like it’d be better to be able to check for existence without having to guarantee that it has existed at least once before.
You could do a check on SubWindow to see if it is null. If thats the case then instantiate the SubWindow otherwise it exists.