Programmatically adding document windows to a MDI

Docking/MDI for WPF Forum

Posted 11 years ago by dean
Avatar
I am trying to get a documentwindow to be opened in a multi window container when i click a button.

When i click the button nothing happens even though i can step through the ScreenButton_Click method.

I have implemented this correctly?
 
        StandardMdiHost MyMDIHost;
        DockSite MyDockSite;
 public override void BeginInit()
        {
            base.BeginInit();
            
            //Create the docking panel
            MyDockSite = CreateApplicationDockSite();

            //Create the WPF docking panel that will be the content of the WPF window.
            DockPanel MyDockPanel = new DockPanel();
            MyDockPanel.LastChildFill = true;

            //Add the docksite and the ribbon.
            //Note: The Actipro Ribbon has to be the last added.  Not sure why - their documentation does not
            //        state why...
            
            MyDockPanel.Children.Add(MyDockSite);
           
            this.ApplicationName = ApplicationInformation.ApplicationTitle;
            this.DocumentName = string.Empty;
            this.Content = MyDockPanel;
        }

        private DockSite CreateApplicationDockSite()
        {
            MyDockSite = new DockSite();
            MyDockSite.Name = "MyDockSite";
            MyDockSite.CanDocumentWindowsClose = false;

            SplitContainer MySplitContainer = new SplitContainer();

            //StandardMdiHost 
            MyMDIHost = new StandardMdiHost();
            MyMDIHost.Name = "MyMDIHost";

            MySplitContainer.Children.Add(MyMDIHost);

            MyDockSite.Content = MySplitContainer;

            return MyDockSite;
        }


        void ScreenButton_Click(object sender, ExecuteRoutedEventArgs e)
        {  
            try
            {

                DocumentWindow x = new DocumentWindow(MyDockSite);
                
                x.Activate();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

Comments (1)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Dean,

You need to insert a Workspace between the SplitContainer and the StandardMdiHost. That could possibly be doing it.


Actipro Software Support

The latest build of this product (v2019.1 build 0684) was released 16 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.