Active Files button on Tabbed MDI container is disabled

Docking/MDI for WPF Forum

Posted 5 years ago by Peter Todd
Version: 14.1.0602
Platform: Silverlight Controls
Environment: Windows 7 (64-bit)
Avatar

I have created a simple demo of my problem (see below). Each time the Add button is clicked (top left) a document is added to the tabbed MDI container. The problem is that the Active Files dropdown button at the top right of the tabbed MDI container remains disabled as I add documents. Strangely, it becomes enabled when I close any of the documents, and remains enabled thereafter. Is this a bug, or am I doing something wrong?

Peter

Here is the XAML for the main window

<Window x:Class="ActiproDockingTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:apd="http://schemas.actiprosoftware.com/winfx/xaml/docking"
        Title="MainWindow" Height="350" Width="525">
	<DockPanel>
		<Button DockPanel.Dock="Top" Content="Add" Click="Add_Click" HorizontalAlignment="Left"/>
		<apd:DockSite>
			<apd:Workspace>
				<apd:TabbedMdiHost>
					<apd:TabbedMdiContainer x:Name="mdiTab"/>
				</apd:TabbedMdiHost>
			</apd:Workspace>
		</apd:DockSite>
	</DockPanel>
</Window>

 And here is the C#

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

namespace ActiproDockingTest
{
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			InitializeComponent();
		}

		int count = 0;

		private void Add_Click(object sender, RoutedEventArgs e)
		{
			int i = ++count;
			AddTab(new TextBlock() { Text = "This is document " + i }, "Document " + i);
		}

		private void AddTab(object tabContent, string title)
		{
			DockingWindow window = new DockingWindow();
			window.Content = tabContent;
			window.Title = title;
			mdiTab.Items.Add(window);
			window.Activate();
		}
	}
}

Comments (2)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Peter,

Without actually running the app, I can see some immediate problems in the code.  First, if you don't define any docking windows in XAML then you should not define the TabbedMdiContainer.  You never want to name instances of any containers (TabbedMdiContainer, ToolWindowContainer) since those are transient objects that change as layouts change.

Secondly you never want to add a docking window to a container manually like you are in AddTab.  That wlil introduce problems so take that Items.Add line out.

To fix those problems, please keep your TabbedMdiHost empty in the XAML.  Then also you should not use the DockingWindow base class, but rather use the DocumentWindow class.  Use a DocumentWindow contructor that takes a DockSite so that it gets registered with the DockSite.  Then call window.Activate() and that's it.  Things will probably work fine after that.


Actipro Software Support

Posted 5 years ago by Peter Todd
Avatar

Thanks for the repsonse. I probably didn't do the best job of converting my actual project to the simplified demo, because in my actual project I don't define the empty TabbedMdiContainer in XAML, I do use either DocumentWindow or ToolWindow rather that the base class DockingWindow (I blame this on carelessly accepting the first intellisence suggestion), and I do use the constructor that takes the DockSite as the argument. The key thing that resolved my problem was your advice to remove the call to MdiContainer.Items.Add--indeed it isn't necessary and then the active files dropdown button is enabled.

Thanks--Peter

The latest build of this product (v2018.1 build 0675) 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.