Docking Window Problem

Docking/MDI for WPF Forum

Posted 9 years ago by Marcus Weaver - Technical Director, Central Precision, Inc
Version: 9.2.0510
Platform: .NET 3.5
Environment: Windows Vista (64-bit)
I installed the newest version and ran into a problem. When I updated my references for Docking/MDI to the new version 9.2 v510, in the designer window I get the unhandled exception below. When I click on "Click Here to Reload The Designer," nothing happens. When I change the reference for Docking/MDI back to version 9.1 507, then rebuild all, the designer shows the document correctly. My project is a tabbed MDI project and this happens to all tabbed documents in the project. I have included my XAML from one of the documents below the exception message in case that helps.


This operation is invalid since the DockingWindow has not yet been registered with a DockSite.
at ActiproSoftware.Windows.Controls.Docking.DockingWindow.Activate(Boolean focus)
at ActiproSoftware.Windows.Controls.Docking.DockingWindow.Activate()
at a.a(ModelItem A_0)
at ActiproSoftware.Products.Windows.Design.PrimarySelectionAdornerProviderBase.Activate(ModelItem item, DependencyObject view)
at Microsoft.Windows.Design.Interaction.AdornerProvider.InvokeActivate(EditingContext context, ModelItem item, DependencyObject view)
at MS.Internal.Features.AdornerProviderFeatureConnector.FeatureProvidersAdded(ModelItem item, IEnumerable`1 extensions)
at Microsoft.Windows.Design.Features.PolicyDrivenFeatureConnector`1.OnPolicyItemsChanged(Object sender, PolicyItemsChangedEventArgs e)
at Microsoft.Windows.Design.Features.PolicyDrivenFeatureConnector`1.OnPolicyAdded(Object sender, PolicyAddedEventArgs e)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at MS.Internal.Features.ItemPolicyConnector.ActivatePolicy(PolicyData policyData)
at MS.Internal.Features.ItemPolicyConnector.OnPolicyRequirementsChanged(Object sender, EventArgs e)
at Microsoft.Windows.Design.RequirementValidator.OnRequirementChanged(Object sender, EventArgs e)
at Microsoft.Windows.Design.RequirementSubscription.OnRequirementChanged()
at Microsoft.Windows.Design.RequiresContextItemAttribute.RequireContextItemSubscription.OnContextItemChanged(ContextItem item)
at Microsoft.Windows.Design.SubscribeContextCallback.Invoke(ContextItem item)
at Microsoft.Windows.Design.EditingContext.DefaultContextItemManager.OnItemChanged(ContextItem item)
at Microsoft.Windows.Design.EditingContext.DefaultContextItemManager.SetValue(ContextItem value)
at MS.Internal.Designer.VSDesigner.VSDesignerClientImpl.RestoreSelection(List`1 selectionOffsetsInXamlFile)
at MS.Internal.Designer.VSDesignerClient.RestoreSelection(List`1 offsetsInXamlFile)
at MS.Internal.Designer.DesignerPane.LoadDesignerView()

-----------------XAML Code-----------------------------------------------------------------

<docking:DocumentWindow x:Class="HardwareMaintenanceDocument"
xmlns:x="" >

<CollectionViewSource x:Key="HardwareCategoriesSource" />
<CollectionViewSource x:Key="HardwareSource" Source="{Binding SelectedItem.Hardware, ElementName=grdCategories}" />
<CollectionViewSource x:Key="PriceBreaksSource" Source="{Binding SelectedItem.PriceBreaks, ElementName=grdHardware}" />

<Grid Height="800" Width="1680">
<TextBlock Height="20" HorizontalAlignment="Left" Margin="8,8,0,0" Name="TextBlock1" Text="To search for a particular piece of hardware, type the name in the box below" VerticalAlignment="Top" Width="413" />
<editors:TextBox Name="txtSearch" Height="21.96" HorizontalAlignment="Left" Margin="10,28,0,0" VerticalAlignment="Top" Width="402" />
<RadioButton Name="rbStartsWith" HorizontalAlignment="Left" Margin="11,52.04,0,0" VerticalAlignment="Top" Width="81.5" Height="19.04" Content="Starts With" IsChecked="True" />
<RadioButton Name="rbContains" HorizontalAlignment="Left" Margin="106,52.04,0,0" VerticalAlignment="Top" Width="81.5" Height="19.04" Content="Contains" />
<RadioButton Name="rbEndsWith" Margin="191.5,52.04,0,0" VerticalAlignment="Top" Height="19.04" Content="Ends With" HorizontalAlignment="Left" Width="81.5"/>
<TextBlock Height="21" HorizontalAlignment="Left" Margin="12,75,0,0" Name="TextBlock2" Text="Categories" VerticalAlignment="Top" Width="64.666" />
<datagrid:ThemedDataGrid Name="grdCategories" AutoGenerateColumns="False" HorizontalAlignment="Left" ItemsSource="{Binding Source={StaticResource HardwareCategoriesSource}}" Margin="12,94,0,12" SelectionMode="Single" VerticalGridLinesBrush="White" Width="365.5" >
<tk:DataGridTextColumn Binding="{Binding Path=Name}" Header="Category Name" />

<datagrid:ThemedDataGrid Name="grdHardware" AutoGenerateColumns="False" ItemsSource="{Binding Source={StaticResource HardwareSource}}" Margin="392,94,323,12" SelectionMode="Extended" >
<tk:DataGridTextColumn Binding="{Binding Name}" Header="Hardware Name" />
<datagrideditors:DataGridDoubleColumn Binding="{Binding Price}" Header="Price" Format="C" />
<tk:DataGridTextColumn Binding="{Binding ParentCategoryName}" Header= "Category Name" IsReadOnly="True" />

<datagrid:ThemedDataGrid Name="grdPriceBreaks" AutoGenerateColumns="False" ItemsSource="{Binding Source={StaticResource PriceBreaksSource}}" Margin="0,94,12,12" SelectionMode="Extended" HorizontalAlignment="Right" Width="298">
<datagrideditors:DataGridInt32Column Header="Qty" SpinnerVisibility="Visible" StepValue="1" Binding="{Binding Qty, UpdateSourceTrigger=PropertyChanged}" Minimum="1" />
<datagrideditors:DataGridDoubleColumn Header="Price" Binding="{Binding Price}" Minimum=".01" Format="C" />

<TextBlock Height="21" HorizontalAlignment="Left" Margin="392,75,0,0" Name="TextBlock3" Text="Hardware" VerticalAlignment="Top" Width="64.666" />
<shared:AnimatedExpander Header="Click to Change Category of Selected Hardware" Height="63.08" Margin="489,4.04,631,0" Name="expChangeCategory" VerticalAlignment="Top" xmlns:shared="">
<Grid Name="MainGrid" >
<ComboBox Margin="10,10,168,0" Name="cboChangeCategory" />
<Button HorizontalAlignment="Right" Margin="0,10,6,0" Name="Button1" Width="75" Click="CancelChangeCategory">Cancel</Button>
<Button HorizontalAlignment="Right" Margin="0,10,87,0" Name="Button2" Width="75" Click="ChangeHardwareCategory">OK</Button>
<TextBlock Height="21" HorizontalAlignment="Right" Margin="0,75,229,0" Name="TextBlock4" Text="Price Breaks" VerticalAlignment="Top" Width="81" />

Comments (3)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Marcus,

Thanks for reporting this issue. We did update the design experience so that if a DocumentWindow/ToolWindow, or one of the children, is selected in the designer then the window would activate itself. This allows you to see the content inside the DocumentWindow/ToolWindow when designing and navigating around.

Based on your code above, I've updated the code to only activate the window if it's registered with a DockSite. Which will work around the issue you are seeing, while still offering the new changes.

This fix will be part of the next maintenance release.

Actipro Software Support

Posted 9 years ago by Marcus Weaver - Technical Director, Central Precision, Inc
Thanks. Based on your reply, it sounds like I may not be using the best programming practices for tabbed MDI. If you have a minute, can you guide me? What in the code should be changed to register it with a docksite at design time? My docking windows are created dynamically at runtime based on user interaction. Here are code snippets from my application. The first one is my Window Loading event...

Private MainMDIHost As TabbedMdiHost

Private Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
ActiproSoftware.Windows.Themes.ThemeManager.CurrentTheme = ActiproSoftware.Windows.Themes.CommonThemeName.Office2007Blue.ToString
MainDockSite.Content = New Workspace
MainMDIHost = New TabbedMdiHost
MainMDIHost.IsCloseButtonOnTab = True
MainDockSite.Workspace.Content = MainMDIHost
MainDockSite.Workspace.Background = New ImageBrush(DirectCast(FindResource("CPIBackground"), ImageSource))
End Sub

The following snippet checks to see if an instance of a docking window is open and activates it. If it is not open already, a new one is created. This prevents multiple windows with the same content from being opened at the same time. My application is for quoting and uses many windows open at the same time

Private Sub LoadMaterialsMaintenance()
'See if the Material Maintenance is already open, if it is, activate it but do not create a new one
Dim tabbedContainer As TabbedMdiContainer = DirectCast(MainMDIHost.Content, TabbedMdiContainer)
If tabbedContainer IsNot Nothing Then
For Each doc As DocumentWindow In tabbedContainer.Items
If doc.Name = "MaterialMaintenanceDocument" Then
Exit Sub
End If
End If
Dim MaterialMaintenanceDocument As New MaterialMaintenanceDocument(MainDockSite, "MaterialMaintenanceDocument", "Material Maintenance")
End Sub

Does everything here look OK?
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Marcus,

Yes, what you have looks fine. Since you have a custom DocumentWindow, that can be designed independently of the MainWindow, there is no DockSite when it's viewed in the designer. That's not really a problem, but the code we added just wasn't expecting a DocumentWindow to be viewed in the designer outside of a DockSite. What you have is a good separation of functionality.

The only thing I would suggest is to set the ThemeManager.CurrentTheme in the application OnStartup. If you look in our Sample Browser, in the WindowsApp.xaml.cs (or .vb) file, you will a a NOTE indicating the best place to set it. Setting that after the Window is loaded, would cause it to reapply the themes needlessly.

Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.