TabbedMdiContainer disapears when removing last item

Docking/MDI for WPF Forum

Posted 11 years ago by uran1
Version: 4.5.0476
Platform: .NET 3.5
Environment: Windows XP (32-bit)
Avatar
Steps to reproduce
  1. Click button in ribbon to add DocumentWindow to container
  2. Close DocumentWindow using cross button on right top sid
  3. Container disapears and adding new DocumentWindow using button from first step does not work

<ribbon:RibbonWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
    xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
    xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
    xmlns:Themes="clr-namespace:ActiproSoftware.Windows.Themes;assembly=ActiproSoftware.Shared.Wpf30"
    xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
    xmlns:Media="clr-namespace:System.Windows.Media;assembly=PresentationCore"
    xmlns:Drawing="clr-namespace:System.Drawing;assembly=System.Drawing"
      x:Class="WpfApplication8.MainWindow"
      ApplicationName="AAA" WindowState="Maximized"  
    Themes:ThemeManager.Theme="Office2007Black"
  
  
  >
    <DockPanel LastChildFill="True" x:Name="MainDockPanel" >
        <ribbon:Ribbon x:Name="ribbon" DockPanel.Dock="Top"  >
            <ribbon:Ribbon.Tabs>
                <ribbon:Tab Label="General">
                    <ribbon:Group Label="Files">
                        <ribbon:Button  Click="ButtonClick" Label="Load plugin"/>
                    </ribbon:Group>
                </ribbon:Tab>
            </ribbon:Ribbon.Tabs>
        </ribbon:Ribbon>
        <docking:DockSite x:Name="dockSite" >
            <docking:Workspace>
                <docking:TabbedMdiHost x:Name="tabbedMdiHost">

                    <docking:TabbedMdiContainer  x:Name="tabbedMdiContainer" Background="Gold">
                       
                    </docking:TabbedMdiContainer>
                </docking:TabbedMdiHost>
            </docking:Workspace>
        </docking:DockSite>
    </DockPanel>
</ribbon:RibbonWindow>

using System.Windows;
using ActiproSoftware.Windows.Controls.Docking;

namespace WpfApplication8
{

    public partial class MainWindow
    {
        public void ButtonClick(object sender, RoutedEventArgs e)
        {
            DocumentWindow window1 = new DocumentWindow {Title = "Title1"};
            tabbedMdiContainer.Items.Add(window1);
        }
    }
}

Comments (1)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
This is again related to your other posts. Instead of having an empty TabbedMdiContainer defined in the TabbedMdiHost (which is bad), just have the TabbedMdiHost.

When you create a DocumentWindow, do NOT use the parameterless constructor. The documentation for that says to never use that constructor when creating DocumentWindows programmatically. Use the other constructors that accept the DockSite parameter, etc.

Create and activate your document window like this:
DocumentWindow documentWindow = new DocumentWindow(dockSite, name, title, image, textBox);
documentWindow.Activate();
That will work as expected.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.