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.
Andrew Smith"] 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. <DataTrigger Binding="{Binding Path=Role, RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}}" Value="SubmenuItem"> <Setter TargetName="closeBtn" Property="Visibility" Value="Collapsed" /> </DataTrigger>
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.
Where would this DataTrigger go?
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.
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?