Get a HostWindow by its Content
In certain cases, you may need to perform specific operations depending on the currently activated HostWindow in regards to the form/user control that it contains.
In order to do this, you should first subscribe to the ActiveWindowChanged event and then execute the following code snippet in the ActiveWindowChanged event handler:
Getting a HostWindow by its content
In order to get a HostWindow that hosts a particular form/user control instance, you should call the GetHostWindows method passing the contained control as a parameter. Supposing that vegetablesForm
is an instance of type VegetablesForm, we can use the following code snippet: