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
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).
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.
Thanks,Michel
OK scratch that... I torture-tested it a bit more and it's still happening, just not as much.
I've now moved that code so that it is called by the Loaded event of the user control that owns the dock manager, where in theory at least the dock manager is probably more keen on getting a document added. I hope that does it, I've got real work to do too. :(
Well when you have time and can provide a sample then I can try to look into it. Also, if you can get it to happen on your system it would be helpful to run Snoop, Mole or some other element viewer tool to inspect the Visual Tree of the DocumentContentHost to see if the element is not there and if it is (which I suspect it would be), what its ActualWidth, Width, Visibility, IsVisible, etc. are for the usercontrol, the containing contentpane, etc.
The sample could take a while - we're beyond late as it is, and I've already spent nearly two days on this little problem alone. In fact if my latest workaround stops working, I may have to drop the dock manager altogether for this specific part of the application... Not something I want to do.
Re: Snoop. I tried that, and it's interesting: The element is not there at all. I could find the splitpane and the tabgrouppane, but there was nothing underneath, and both had visibility="Collapsed" (this is why I hardcoded the visibility in each element above - I was trying to see if it would help.) The actual content pane was not there, nor, of course, was the content of the content pane.
Knowing that the ContentPane is not in the visual tree is actually a big help. I'll try to see if I have any luck reproducing the issue. To try and ensure I try the right steps, in what event are you creating that UserControl (the one that contains the xamDockManager whose ContentPane in the DocumentContentHost is disappearing) and what are you eventually parenting that UserControl into (e.g. a tab item's content, the content of a window, the content of a page, etc.)?
I'm home now, so just working from memory:
I have a XamRibbon and one of the buttons is used to call that specific function. As we speak, the code-behind instantiation (the stuff I put in an earlier post here) is just in the Clicked event of that button (I know, this should really go elsewhere - I'm still just doing the general plumbing.) That Clicked event is in the code-behind of the application's main window, which contains the ribbon and the various user controls that display whatever functionality the user selects (a two-row grid, basically.) Now the code that instantiates the content pane, I moved from that clicked event to the loaded event of the UserControl (the one that contains the dock manager.) "So far, so good".
So we have:
MainWindow (Window control)-----Grid ---- Ribbon (grid row 0) ---- UserControl (grid row 1)
Grid row 1 actually contains several user controls, but only the currently selected one is visible at any one time, the others are collapsed. The two that are used all the time are declared in the XAML for MainWindow and instantiated at load time - I don't have any problems with the dock manager in those. The other ones are "rarely" used, which is why I'm only instantiating them on demand. This is where I have a problem. So... Answer to the last question: A grid is the parent of the UserControl that contains the misbehaving dock manager.
Tomorrow I'll put the code back in place to reproduce the problem (assuming my current workaround still works anyway :)) and take a couple of screen shots of the visual tree in Snoop. Maybe that'll help you more than me trying to word this stuff here.
Snoop screenshot with contentpane (this is with my code-behind work around, which creates the content pane in the user control's Loaded event):
Snoop screenshot without contentpane: This is when the content pane is declared in the XAML (but the actual user control is still instantiated in code-behind). As you can see, the tree stops at the TabGroupPane