Cannot add content to Tabbed MDI Host

Docking/MDI for WPF Forum

Posted 10 years ago by Mike Benson - CTO, Abakos, Inc.
Version: 9.1.0503
Avatar
I am trying to add a control at the top of the tabbed mdi host. It works great until I programatically add a document. At that point my control is destroyed. Can you tell me how to accomplish this?


Here is a sample to recreate the issue, you can do everything but if you click on the open button, my control is destroyed. If you close the two hard coded docs, you will get an exception.

I am willing to retheme the host if necessary, though it seems like I should not have to.

Also, I tried to submit this to the support but the captcha is not able to correctly validate the text that was entered.


XAML:

<Window x:Class="WpfApplication4.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:navigation="http://schemas.actiprosoftware.com/winfx/xaml/navigation"
    xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
    xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
    xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking" 
    xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
    Title="Window1" Height="600" Width="600">
    <Grid>
        <Grid themes:ThemeManager.Theme="Office2007Blue">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Grid Visibility="Hidden">
                <Frame x:Name="NavigationFrame" Grid.Row="0" Grid.Column="0" Width="0" Height="0" Visibility="Hidden"/>
            </Grid>

            <shared:PixelSnapper
                        Grid.Column="0"
                        Grid.Row="0"
                        Grid.ColumnSpan="2"
                        >
                <Grid>
                    <Grid
                                x:Name="TopMenu"
                                Height="auto"
                                Width="Auto"
                                VerticalAlignment="Top"
                                HorizontalAlignment="Right"
                                Panel.ZIndex="1000"
                                />
                    <ribbon:Ribbon x:Name="Desktop_RibbonStrip" IsQuickAccessToolBarCustomizationEnabled="True" IsCustomizeQuickAccessToolBarMenuItemVisible="True">
                        <ribbon:Ribbon.QuickAccessToolBarCommonItems>
                            <ribbon:Button Id="Save" Command="ApplicationCommands.Save" Label="Save" />
                            <ribbon:Button Id="Undo" Command="ApplicationCommands.Undo" Label="Undo" />
                            <ribbon:Button Id="Redo" Command="ApplicationCommands.Redo" Label="Redo" />
                            <ribbon:Button Id="New" Command="ApplicationCommands.New" Label="New"  />
                            <ribbon:Button Id="Delete" Command="ApplicationCommands.Delete" Label="Delete"  />
                            <ribbon:Button Id="Refresh" Command="NavigationCommands.Refresh"  Label="Refresh"  />
                            <ribbon:Button Id="SelectAll" Label="Select All" />
                            <ribbon:Button Id="ClearAll"  Label="Clear All" />
                        </ribbon:Ribbon.QuickAccessToolBarCommonItems>

                        <ribbon:Ribbon.QuickAccessToolBarItems>
                            <ribbon:Button Id="Save" Command="ApplicationCommands.Save" Label="Save" />
                            <ribbon:Button Id="Undo" Command="ApplicationCommands.Undo" Label="Undo" />
                            <ribbon:Button Id="Redo" Command="ApplicationCommands.Redo" Label="Redo" />
                        </ribbon:Ribbon.QuickAccessToolBarItems>
                        <ribbon:Ribbon.ApplicationMenu>
                            <ribbon:ApplicationMenu x:Name="applicationMenu">
                                <ribbon:ApplicationMenu.AdditionalContent>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="22"/>
                                            <RowDefinition Height="auto"/>
                                            <RowDefinition Height="*"/>
                                        </Grid.RowDefinitions>

                                        <TextBlock Grid.Column="0" Grid.Row="0" Text="Recent Items" FontSize="11" FontWeight="Bold"  Foreground="Navy" Margin="10,4,10,4" />
                                        <ItemsControl Grid.Row="1" x:Name="recentItems" >
                                            <ItemsControl.ItemTemplate>
                                                <DataTemplate>
                                                    <Grid Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth}">
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="*" />
                                                            <ColumnDefinition Width="34" />
                                                        </Grid.ColumnDefinitions>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="25"/>
                                                        </Grid.RowDefinitions>

                                                        <Button
                                                                    Style="{DynamicResource MainMenuButtonStyle}"
                                                                    Grid.Column="0"
                                                                    Grid.Row="0"
                                                                    Grid.ColumnSpan="2"
                                                                    Command="ApplicationCommands.Open"
                                                                    CommandParameter="{Binding Path=Uri}"
                                                                    VerticalAlignment="Center"
                                                                    >
                                                            <Button.Content>
                                                                <Grid>
                                                                    <Grid.ColumnDefinitions>
                                                                        <ColumnDefinition Width="12" />
                                                                        <ColumnDefinition Width="22" />
                                                                        <ColumnDefinition Width="*" />

                                                                        <ColumnDefinition Width="34" />
                                                                    </Grid.ColumnDefinitions>
                                                                    <TextBlock Grid.Column="0" Text="{Binding Path=MRUIndexText}" Foreground="Navy" TextDecorations="Underline" VerticalAlignment="Center" />
                                                                    <Image Grid.Column="1" Source="{Binding Path=DisplayImage}" Width="16" Height="16" VerticalAlignment="Center" HorizontalAlignment="Center" />
                                                                    <TextBlock Grid.Column="2" Text="{Binding Path=DisplayName}" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Foreground="Navy" VerticalAlignment="Center" />
                                                                </Grid>
                                                            </Button.Content>
                                                        </Button>
                                                        <ToggleButton
                                                                    Style="{DynamicResource MainMenuPinButtonStyle}"
                                                                    Grid.Column="1"
                                                                    Grid.Row="0"
                                                                    Tag="{Binding Path=MRUIndex}"
                                                                    IsChecked="{Binding Path=IsPinned}"
                                                                    />
                                                    </Grid>
                                                </DataTemplate>
                                            </ItemsControl.ItemTemplate>
                                        </ItemsControl>
                                    </Grid>
                                </ribbon:ApplicationMenu.AdditionalContent>
                            </ribbon:ApplicationMenu>
                        </ribbon:Ribbon.ApplicationMenu>
                        
                    </ribbon:Ribbon>
                </Grid>
            </shared:PixelSnapper>
            <shared:PixelSnapper Grid.Column="0" Grid.Row="1" >
                <shared:ResizableContentControl ResizeMode="Horizontal" >
                    <navigation:NavigationBar
                                x:Name="Desktop_SideNavigationBar"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Margin="0,0,0,0"
                                IsCustomizationEnabled="True"
                                themes:ThemeManager.Theme="Office2007Blue"
                                ContentWidth="150">
                        <navigation:NavigationPane Header="Test" >
                            <StackPanel>
                                <Button Content="Open" Click="OpenWindow"/>
                            </StackPanel>                                
                        </navigation:NavigationPane>
                    </navigation:NavigationBar>
                    
                </shared:ResizableContentControl>
            </shared:PixelSnapper>

            <docking:DockSite Name="docksite" Grid.Column="1" Grid.Row="1" >
                <docking:DockSite.AutoHideLeftContainers>
                    <docking:ToolWindowContainer >
                        <docking:ToolWindow Title="Tool Window 2" />
                    </docking:ToolWindowContainer>
                </docking:DockSite.AutoHideLeftContainers>
                <docking:DockSite.AutoHideRightContainers>
                    <docking:ToolWindowContainer >
                        <docking:ToolWindow Title="Tool Window 2" />
                    </docking:ToolWindowContainer>
                </docking:DockSite.AutoHideRightContainers>
                <docking:DockSite.AutoHideTopContainers>
                    <docking:ToolWindowContainer >
                        <docking:ToolWindow Title="Tool Window 3" />
                    </docking:ToolWindowContainer>
                </docking:DockSite.AutoHideTopContainers>
                <docking:DockSite.AutoHideBottomContainers>
                    <docking:ToolWindowContainer >
                        <docking:ToolWindow Title="Tool Window 4" />
                    </docking:ToolWindowContainer>
                </docking:DockSite.AutoHideBottomContainers>
                
                <docking:SplitContainer >
                    <docking:SplitContainer Orientation="Vertical">
                        <docking:Workspace>

                            <docking:TabbedMdiHost x:Name="TabbedMdiHost" IsCloseButtonOnTab="True" TabPlacement="Top" IsImageOnTab="True" >
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <shared:AnimatedExpander Grid.Row="0" IsExpanded="False" HeaderBackgroundNormal="Orange" >
                                        <shared:AnimatedExpander.Header>
                                            <TextBlock Text="Expander"/>
                                        </shared:AnimatedExpander.Header>
                                        <StackPanel>
                                            <TextBlock Text="Item 1"/>
                                            <TextBlock Text="Item 2"/>
                                            <TextBlock Text="Item 3"/>
                                            <TextBlock Text="Item 4"/>
                                        </StackPanel>
                                    </shared:AnimatedExpander>
                                    
                                    <docking:TabbedMdiContainer Grid.Row="1" x:Name="NavigationTab">

                                        <docking:DocumentWindow Title="Doc 1"/>
                                        <docking:DocumentWindow Title="Doc 2"/>
                                    </docking:TabbedMdiContainer>
                                </Grid>                                    
                            </docking:TabbedMdiHost>

                        </docking:Workspace>
                    </docking:SplitContainer>
                </docking:SplitContainer>
            </docking:DockSite>


        </Grid>
    </Grid>
</Window>
And the code behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ActiproSoftware.Windows.Controls.Docking;

namespace WpfApplication4
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            TabbedMdiContainer tm;
            

        }

        private void OpenWindow(object sender, RoutedEventArgs e)
        {
            DocumentWindow dw = new DocumentWindow(docksite, "_" + Guid.NewGuid().ToString("N"), "New Window", null, null);
            dw.Activate();
            
        }
    }
}

Comments (3)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mike,

Adding custom content to the TabbedMdiHost is not supported. You may want to take a look at the Docking & MDI Control Hierarchy topic in the help file.

You can add custom content to the Workspace, but with the current release the MDI host is required to be the direct child of the Workspace. The next maintenance release includes an update that removes this requirement.

So just to be clear, with the next build's changes, you can move the Grid to the Workspace and then put the TabbedMdiHost in the Grid. But you can't put custom content in the TabbedMdiHost.

[Modified at 10/13/2009 12:29 PM]


Actipro Software Support

Posted 10 years ago by Mike Benson - CTO, Abakos, Inc.
Avatar
Any idea when the next release is coming?
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Should be sometime in the next couple weeks.


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.