Hi,
I'm having a weird problem in the dock manager, using the latest version (2009.2). I've been using it for over a year and never experienced this before:
I have a user control which contains a dock manager. Its panes and the DocumentControlHost all contain user controls (all WPF controls - no WinForms stuff.) *Sometimes* when I open the control, the DocumentControlHost is not displayed: No tab, no content. Start the application again, and then it shows up. It might work a few times in a row, then stop again(!)
Thinking the control in the DocumentControlHost could be the problem, I created a test user control with only a textbox in it, and experienced the same kind of behaviour.
The only difference between this one and the others (which do not seem to be exhibiting this behaviour so far) is that this control is instantiated in code-behind, on demand. The others are instantiated at application startup. This one here is not used on a regular basis, so I only instantiate it on demand to save memory.
The dock manager declaration in XAML is basically the same as with my other controls (the ones that work fine), save of course for the actual controls displayed within the panes.
I've been running in circles for a couple of days now and I'm running out of ideas of what to try. The intermittent nature of the problem makes it even harder to debug (I thought I had resolved it a couple of times, only for it to reappear later...)
Suggestions?
Thanks,MIchel
I had already tried that (but tried again, just in case my memory was acting up), and no go. In fact, it seemed to make matters worse(!)
I commented out the ContentPane code in XAML (leaving only the splitpane and tabgrouppane) and replaced it with code-behind:
Dim _test As New UserRequestsDetails() _test.DataContext = _rulingRequests.RequestInformation Dim _cp As ContentPane = _rulingRequests.UserRequestsDockManager.AddDocument(My.Resources.UIResources.Dock_UserRequestDetails_PaneHeader, _test) _cp.Name = "UserRequestDetailsPane" _cp.Activate()
So far (since doing this), the control has shown up every time I started the application - so this seems to be a workaround (I'll keep testing just to make sure - no point in me continuing other work until I'm sure this is fixed - it's central to the new functionality I'm implementing.)
Note that it was not only the content of the content pane that was missing - even the Tab was missing - basically, the screen looked the way it does when you close the last document and you get an empty space. I went in there with the Snoop utility and the various panes (from the splitpane) were collapsed (no, I don't do that anywhere.)
I'm almost positive this started after upgrading to 2009.2. My other usercontrols that use the dock manager do not seem to be affected at all - but as I mentioned earlier, this is the only one that's instantiated through code-behind - the others are all declared in the XAML of the main window and instantiated automatically at startup. Maybe this is a random side effect related to the fix you mentioned above (I say random because this was not happening all the time... Hellish debugging...)
Thanks,Michel
Can you remove the Width and Height bindings on UserRequestsWindow (or set them to Auto if you have left the Width/Height set in the xaml for that usercontrol)? In general it is not a good idea to bind the Width/Height to the ActualWidth/ActualHeight of the element or any of its ancestors. If UserRequestsWindow is measured/arranged at say 10,10 then you are setting the Width/Height to 10x10. When it is measured next, even if you measure it with a larger size the element will only measure its children with 10x10 - i.e. it will not get any bigger.
The XamDockManager is in a grid in a UserControl (no other content in the grid.) I have a couple of other similar controls (all instantiated through XAML, however) that are defined the same way and work fine.
Here's the XAML definition of the Dock Manager (sorry, I have no idea how to post formatted code here). More comments plus some code-behind will follow this:
<igDock:XamDockManager x:Name="UserRequestsDockManager" Theme="{Binding Path=Theme, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserRequestsControl}}}" PaneDragStarting="UserRequestsDockManager_PaneDragStarting" PaneNavigatorButtonDisplayMode="Never" > <!-- The document area - Holds User Request Details --> <igDock:DocumentContentHost> <igDock:SplitPane x:Name="UserRequestDocumentSplitPane" Visibility="Visible"> <igDock:TabGroupPane x:Name="UserRequestDocumentTabGroupPane" Visibility="Visible" > <igDock:ContentPane x:Name="UserRequestPane" Tag="{Loc Dock_UserRequestDetails_PaneHeader}" Header="{Loc Dock_UserRequestDetails_PaneHeader}" Image="..\Images\icons\DockManager\descriptors_16x16.png" HorizontalAlignment="Left" VerticalAlignment="Top" Visibility="Visible" Closed="ContentPane_Closed" > <local:UserRequestsDetails x:Name="UserRequestsWindow" Visibility="Visible" Width="{Binding ElementName=UserRequestPane, Path=ActualWidth}" Height="{Binding ElementName=UserRequestPane, Path=ActualHeight}" DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:UserRequestsControl}, AncestorLevel=1}, Path=RequestInformation}" /> </igDock:ContentPane> </igDock:TabGroupPane> </igDock:SplitPane> </igDock:DocumentContentHost> <igDock:XamDockManager.Panes> <!-- Filter Pane, initially docked to the left This pane is declared first so that it takes up the full height. --> <igDock:SplitPane igDock:XamDockManager.InitialLocation="DockedLeft" x:Name="FilterSplitPane" > <igDock:ContentPane x:Name="UserRequestFilterPane" Closed="ContentPane_Closed" Header="{Loc UserRequestFilter_SearchFilter_Label}" Tag="{Loc UserRequestFilter_SearchFilter_Label}" > <local:UserRequestFilter x:Name="UserRequestFilterWindow" Theme="{Binding Path=Theme, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserRequestsControl}}}" DomainId="{Binding Path=DomainId, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserRequestsControl}}}" AppLanguage="{Binding Path=AppLanguage, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserRequestsControl}}}" DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:UserRequestsControl}, AncestorLevel=1}, Path=RequestSearchFilter}" /> </igDock:ContentPane> </igDock:SplitPane> <igDock:SplitPane x:Name="TopSplitPane" igDock:XamDockManager.InitialLocation="DockedTop" SplitterOrientation="Vertical" > <igDock:ContentPane igDock:SplitPane.RelativeSize="60,60" x:Name="UserRequestListPane" Image="..\Images\icons\DockManager\descriptorsearch_16x16.png" Tag="{Loc Dock_UserRequestList_PaneHeader}" Header="{Loc Dock_UserRequestList_PaneHeader}" CloseAction="HidePane" Closed="ContentPane_Closed" > <local:UserRequestsList x:Name="UserRequestsListWindow" DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:UserRequestsControl}, AncestorLevel=1}, Path=RequestList}" MinHeight="20" AppLanguage="{Binding Path=AppLanguage, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserRequestsControl}}}" /> </igDock:ContentPane> </igDock:SplitPane> <!-- Bottom split pane - Holds User Request Events --> <igDock:SplitPane x:Name="UserRequestEventsSplitPane" igDock:XamDockManager.InitialLocation="DockedBottom" > <igDock:ContentPane x:Name="UserRequestEventsPane" Image="..\Images\icons\DockManager\itemdetails_active_16x16.png" Tag="{Loc Dock_UserRequestEvents_PaneHeader}" Header="{Loc Dock_UserRequestEvents_PaneHeader}" Closed="ContentPane_Closed" > <local:UserRequestEvents x:Name="UserRequestEventsWindow" MinHeight="20" DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:UserRequestsControl}, AncestorLevel=1}, Path=RequestInformation}" > </local:UserRequestEvents> </igDock:ContentPane> </igDock:SplitPane> </igDock:XamDockManager.Panes></igDock:XamDockManager>
The "UserRequestDetails" control is the one not showing up - or I should say, that shows up only when it feels like it.
Here's how I instantiate it in code-behind (I'm sure there's a better way to do this, but could not find anything, so this "works" for now:)
_rulingRequests = New UserRequestsControl(UserRequestsControl.RequestType.Ruling) Dim _themeBinding As Binding = New Binding("Theme") _themeBinding.ElementName = "CCSWPFRibbon" BindingOperations.SetBinding(_rulingRequests, UserRequestsControl.ThemeProperty, _themeBinding) Dim _layoutLockedBinding As Binding = New Binding("IsLayoutLocked") _layoutLockedBinding.ElementName = "CCSMainWindow" BindingOperations.SetBinding(_rulingRequests, UserRequestsControl.IsLayoutLockedProperty, _layoutLockedBinding) Dim _appLanguageBinding As Binding = New Binding("ApplicationLanguage") _appLanguageBinding.Source = Application.Current BindingOperations.SetBinding(_rulingRequests, UserRequestsControl.AppLanguageProperty, _appLanguageBinding) 'Dim _domainIdBinding As Binding = New Binding("DomainId") '_domainIdBinding.ElementName = "CCSMainWindow" 'BindingOperations.SetBinding(_rulingRequests, UserRequestsControl.DomainIdProperty, _domainIdBinding) MainWindowGrid.Children.Add(_rulingRequests)
"MainWindowGrid" is a grid in the main window (right... :)) which contains two rows: The first has a XamRibbon, the second has whatever user control is "current" (the other ones are collapsed.) I set Grid.Row="1" in the XAML for the user control, so it appears in the right place - it's just the document (UserRequestDetail) that doesn't show up. As I mentioned in the other post, I don't think UserRequestDetail is the problem, since even a simple control with only a textbox in it exhibits the same behaviour.
I tried adding a call to ApplyTemplate at the end of the code-behind code, no luck (though there was some false hope for a couple of minutes.) Maybe that should go elsewhere (if it's in any way related.)
This is seriously bugging me since this new functionality is due in about two weeks from now.
Could you possibly post a sample of the problem or at least a snippet of how you are creating the control in code and some info about where the xamDockManager will be hosted? There was a fix to ensure that ContentPanes that are not referenced within the dockmanager are removed so maybe that is related. There was one issue regarding that fix that was recently reported and will be in this next hotfix where if you had a xamDockManager on a TabControl in a tab that was not selected, unpinned panes were being removed. The workaround I gave for that issue was to force the template of the xamDockManager to be applied (using the ApplyTemplate method).