title: How to find a WinForms control's owner form if it is nested into ElementHost?
body: <p>One of our customers hosts our WinForms .NET grid control iGrid.NET (<a href="http://www.10tec.com/" rel="nofollow">http://www.10tec.com/</a>) inside a WPF ElementHost container together with other WPF controls. It may look strange as it's a WinForms control inside a WPF host inside a WinForms form, but they have no choice because of the other WPF stuff they use (it's the AvalonDock <a href="http://avalondock.codeplex.com/" rel="nofollow">http://avalondock.codeplex.com/</a> docking container).</p>
  
  <p>The problem is that our .NET datagrid control's infrastructure requires to know the parent WinForms form, but the following construction we use for that always return null in this situation:</p>
  
  <pre><code>Form myTopLevelOwnerForm = fCurrentGrid.TopLevelControl as Form;
  </code></pre>
  
  <p>I.e. the standard Control.TopLevelControl property intended for this purpose returns null - though most likely it should be so in the case of WPF host.</p>
  
  <p>The question is: are there other ways to know the parent form from the current control's code? Say, using WinAPI handles or better other native .NET memebrs?</p>