How do I create a custom contentpane header? I naively tried:
<ContentPane ...>
<ContentPane.Header>
<TextBox .... />
</ContentPane.Header>
</ContentPane>
But it doesn't work.
There's two different things here. The error when you set the Header to an element seems like a bug and should be reported to the support group. That being said, I would recommend against putting elements into the Header or TabHeader. A wpf element can only be in 1 part of the visual tree and the Header & TabHeader of the pane are used for several things. The Header is used as the default TabHeader so you would have to set the Header & TabHeader to different objects for every pane you define. The TabHeader will also be used within the various context menus - e.g. the unpinned tray menu and the active files menu. The pane Header can also be used within the pane navigation window so you could well find that the element disappears from the header area and appears in the other area. This is what will happen when you try putting elements into a combobox and then select one of them - it will disappear from the dropdown and appear in the edit area and since the dropdown knows nothing about the move it will not be shown there again even if you select another item.
Hi Andrew,
ContentPane is a HeaderedContentControl, which means I could push any control inside like this:
<Button Content="fff"/>
This construct actually constantly fails with 'already has a logical child' wpf exception while it perfectly works for HeaderedContentControl.
The same happens when I try to set TabHeader. I think you should not force using the HeaderTemplate/TabHeaderTemplate for setting this. It's rather annoying. Why should I provide a data entity + data template when I already have a (working) User Control which represents my header?
Moreover, I think such design violates the meaning of Headered Control and its Header property.
Thanks.
Ah great, that worked! So workaround the padding issue, I used:
<DataTemplate x:Key="dockTabTemplate">
<TextBlock FontSize="12" Margin="1,2,3,3" FontWeight="Bold" Text="{TemplateBinding Content}" />
</DataTemplate>
I tried that out and it worked just fine. Is it possible that you mean that tab item header in which case you would use the TabHeaderTemplate property?
Thanks Andrew, can you give me an example of providing a custom HeaderTemplate? I tried something simple like:
<DataTemplate x:Key="dockHeaderTemplate">
<TextBlock FontSize="16" Foreground="Red" Text="John was here" />
..and used it like this
.. HeaderTemplate="{StaticResource dockHeaderTemplate}"
but it had no effect