WPF Window

Daniele Parasporo 46 Reputation points
2022-08-10T09:38:32.13+00:00

Is it possible to insert a child window in WPF like on Windows form ?, as you can see in the attached image.
Or to better explain a window within another window

The image below is Windows Form
229941-image.png

WIndows Form code

        private void activeToolStripMenuItem_Click(object sender, EventArgs e)  
        {  
            this.IsMdiContainer = true;  
  
            Form ActiveEvents = new EventOpenList();  
            ActiveEvents.MdiParent = this;  
            ActiveEvents.Show();  
            ActiveEvents.BringToFront();  
        }  
Developer technologies Windows Forms
Developer technologies Windows Presentation Foundation
Developer technologies C#
{count} vote

Accepted answer
  1. Reza Aghaei 4,986 Reputation points MVP Volunteer Moderator
    2022-08-10T13:37:12.143+00:00

    A window in WPF is always top-level. So there's no exact equivalent of WinForms MDI or WinForms non-top-level forms as a built-in feature in WPF.

    Instead, you can create a UserControl and add it to the window programmatically. For example, assuming you have a control called UserControl1 and a TabControl having tabControl1 as its name, then you can handle click event of a button and add an instance of the UserControl1 as content of the tab item:

    var page = new UserControl1();  
    var tabItem = (TabItem)tabControl1.Items[0];  
    tabItem.Content = page;  
    

    Alternatively, you may want to use AvalonDock or one of its forks.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.