It is necessary by pressing the button to display the form on the panel (stackpanel) or another component (TabControl etc). For winforms is not difficult:

Form2 frm = new Form2(); frm.TopLevel = false; frm.Visible = true; frm.FormBorderStyle = FormBorderStyle.None; frm.Dock = DockStyle.Fill; this.Panel1.Focus(); this.Panel1.Controls.Add(frm); 

But how to do it in wpf? Tried like this:

 Form2 frm = new Form2(); panel_info.Children.Add(frm); //stackpanel 

so

 Form2 frm = new Form2(); tb.Children.Add(frm); //TabControl 

I get an error Объект Window должен быть корнем дерева. Нельзя добавить объект Window как дочерний объект для Visual. Объект Window должен быть корнем дерева. Нельзя добавить объект Window как дочерний объект для Visual.

a little googling stumbled upon the link http://www.codescratcher.com/wpf/mdi-parent-window-in-wpf/ , but because there you need to connect a third-party libu, it does not suit me. Is there a way to implement this in standard ways? I do not resort to third-party libs and TP

  • It is not clear what you need to get, can I add a screenshot? - user227049
  • Form2 is used somewhere as a separate window or only as a nested one? - Artem Nikolayevich
  • @FoggyFinder I need something like this youtube.com/watch?v=8Smc7-5lYcE , only for wpf. Tobish, I select a certain line in the treeview and depending on what I selected this or that infa appears, there are a lot of information and it seemed to me more convenient with the form - Lolidze
  • You just need to bind the SelectedItem from the ListView to the ContentPresenter - user227049
  • @ ArtemNikolaevich I created it only for this purpose, I don’t use it anywhere else. What would be more clear, then watch the video that I posted above - Lolidze

0