By default, the TabGroupPane within the DocumentContentHost shows a common Close (little x) button at the far right, which when clicked closes the currently active ContentPane. How do we change this so the Header within each ContentPanel has the Close button as well?
If this is possible using styles or templates, a detailed example would be much appreciated.
When a ContentPane is within a DocumentContentHost it doesn't show a header so you''re probably referring to the tab item, which is actually an instance of a PaneTabItem. I can think of a couple of options. You can retemplate the PaneTabItem so that it contains a Button whose command is ContentPaneCommands.Close with a CommandTarget of its Pane property. Another approach would be to set the TabHeaderTemplate to a DataTemplate that contains a button with the same command(target) I mentioned for the previous approach.
e.g. The datatemplate could be something like:
Then set the TabHeaderTemplate on the ContentPane to that:
Very nice Template, it basically works really well!
However, I noticed that the close button is also shown in the files menu. This is not a real problem, but somehow the command target is lost. The following error appears in the output (in VS debug mode):
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Infragistics.Windows.DockManager.PaneTabItem', AncestorLevel='1''. BindingExpression:Path=Pane; DataItem=null; target element is 'Button' (Name='closeBtn'); target property is 'CommandTarget' (type 'IInputElement')
As a effect, the closeButton does not work as intended. Is it possible to alter the template, so that the close button does not appear in the files menu?
Thanks,Patrick
Good point. I had forgotten that we use the tab related properties for the menu items as well. In that case the best option would be to use the TabHeaderSelector so that you can conditionally return this datatemplate when the container handed to the selector is the PaneTabItem. Alternatively you could try to use a findancestor binding to look for an ancestor menuitem and then hide the close button. e.g.
I have a situation where I added an attached property that I set for ContentPanes, Category. I customized the tab template so that my tabs read Category: Header (two text blocks with different styles).
I would like to update the files menu to have the same appearance. I tried using a DataTemplate as was discussed here but I'm not sure how to get the Category value from my panes from this template. Is there any way to get to the pane when this data template is used within the files menu?
Currently there is no event associated with the display of this menu so there isn't a direct means of controlling this. The only option I can think right now, which would be a bit involved, would be to retemplate the TabGroupPane and use a custom MenuItem class for the PART_FilesMenuItem. In that class you would override the OnSubmenuOpened, call the base to have the event get raised and then maniipulate the order of the items.
Works perfectly thanks, yet it leads to another question.
My next task would be to see if I can arrange the content by alphabetical order and/or by the category. Is this possible?
There are 2 situations currently where the xamDockManager will represent a ContentPane by a MenuItem - one is when right clicking in the unpinned tab area and another is when using the files menu. The only common property that exposes the ContentPane on the menu item is the CommandTarget property so you could possibly do a findancestor binding looking for MenuItem and if found use its CommandTarget.