Problem

Docking Window Problem

Posted 4 years ago by Avatar Marcus Weaver - Technical Director, Central Precision, Inc
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.

Thanks
Marcus


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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
xmlns:tk="http://schemas.microsoft.com/wpf/2008/toolkit"
xmlns:datagrid="http://schemas.actiprosoftware.com/winfx/xaml/datagrid"
xmlns:editors="clr-namespace:ActiproSoftware.Windows.Controls.Editors;assembly=ActiproSoftware.Editors.Wpf30"
xmlns:datagrideditors="http://schemas.actiprosoftware.com/winfx/xaml/datagrideditors"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

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

<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" >
<datagrid:ThemedDataGrid.Columns>
<tk:DataGridTextColumn Binding="{Binding Path=Name}" Header="Category Name" />
</datagrid:ThemedDataGrid.Columns>
</datagrid:ThemedDataGrid>

<datagrid:ThemedDataGrid Name="grdHardware" AutoGenerateColumns="False" ItemsSource="{Binding Source={StaticResource HardwareSource}}" Margin="392,94,323,12" SelectionMode="Extended" >
<datagrid:ThemedDataGrid.Columns>
<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.Columns>
</datagrid:ThemedDataGrid>

<datagrid:ThemedDataGrid Name="grdPriceBreaks" AutoGenerateColumns="False" ItemsSource="{Binding Source={StaticResource PriceBreaksSource}}" Margin="0,94,12,12" SelectionMode="Extended" HorizontalAlignment="Right" Width="298">
<datagrid:ThemedDataGrid.Columns>
<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" />
</datagrid:ThemedDataGrid.Columns>
</datagrid:ThemedDataGrid>

<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="http://schemas.actiprosoftware.com/winfx/xaml/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>
</Grid>
</shared:AnimatedExpander>
<TextBlock Height="21" HorizontalAlignment="Right" Margin="0,75,229,0" Name="TextBlock4" Text="Price Breaks" VerticalAlignment="Top" Width="81" />
</Grid>
</docking:DocumentWindow>

Comments (3)

Posted 4 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 4 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
doc.Activate()
Exit Sub
End If
Next
End If
Dim MaterialMaintenanceDocument As New MaterialMaintenanceDocument(MainDockSite, "MaterialMaintenanceDocument", "Material Maintenance")
MaterialMaintenanceDocument.Activate()
End Sub


Does everything here look OK?
Posted 4 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
Information The latest build of this product (2014.1 build 0601) was released 29 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.