Dinesh Kudale

Dinesh Kudale

  • 1.5k
  • 127
  • 16.9k

Is it possible to add another Windows form inside MainWindow form ?

May 19 2021 9:05 AM
In MainWindow.xaml: 
  1. <avalonDock:LayoutDocument x:Name="docBlock1" ContentId="contentBlock1" Title="Block 1">  
  2.            <StackPanel x:Name="spBlock1" Loaded="spBlock1_Loaded" />  
  3.          </avalonDock:LayoutDocument>   
 
 It is a 'Block1' tab window Inside MainWindow. I have implemented AvalonDock inside MainWindow for docking purposes. 
 
In MainWindow.xaml.cs 
  1. private void spBlock1_Loaded(object sender, RoutedEventArgs e)  
  2. {                          
  3.     WindowInteropHelper windowHwnd = new WindowInteropHelper(this);              
  4. }  
WindowInteropHelper() method is from the Windows C# project. We have DLL of this Windows C# project. We don't have any source code for this project. My application is in WPF C#. I am calling WindowInteropHelper() inside my WPF project's event. The purpose of this method is to add one user control to the form.
But this WindowInteropHelper() takes only one parameter and it must be the 'Window' parameter. Please, see below-attached image.
 
But I want to use the same control inside my 'Block 1' tab. But in this WindowInteropHelper() method call, I have passed 'this' keyword. 'this' is pointing to MainWindow. Hence control will see outside of the 'Block 1' tab. Is it possible to show this control inside the 'Block 1' tab? How can I achieve it? Is it possible to add another 'Window' form inside that 'Block 1'? Then I will pass this added new form in place of 'this' keyword to achieve my task.
 
Thanks in advance. 

Answers (2)