Hi
I have a XamDocManager that contains SplitPanes, the last ones contain ContainPanes.
I need to cusomize the Header of the ContentPane. Actually I need to add two buttons that should appear right after the basic ones(close, hide etc) and they should be very similar to them (i.e. there should be two add buttons like "+" that will have the same style). At the end I need to do this programatically. Now I have successed with adding buttons but they looks awfully :)
Here the code I have:
DataTemplate GetHeaderTemplate()
{
FrameworkElementFactory headerContainerElement = new FrameworkElementFactory(typeof(WrapPanel));
FrameworkElementFactory labelElement = new FrameworkElementFactory(typeof(TextBlock));
labelElement.SetValue(TextBlock.TextProperty, "Title");
headerContainerElement.AppendChild(labelElement);
FrameworkElementFactory addServiceButton = new FrameworkElementFactory(typeof(Button));
addServiceButton.SetValue(Button.ContentProperty, "Add Service");
addServiceButton.AddHandler(Button.ClickEvent, new RoutedEventHandler((o, e) => { AddServiceToGroup(group, groupControl); }));
headerContainerElement.AppendChild(addServiceButton);
FrameworkElementFactory addCounterButton = new FrameworkElementFactory(typeof(Button));
//addCounterButton.SetValue(Button.StyleProperty, (Style)FindResource("AddMonitoringElemntButtonStyle"));
addCounterButton.SetValue(Button.ContentProperty, "Add Counter");
addCounterButton.AddHandler(Button.ClickEvent, new RoutedEventHandler((o, e) => { AddCounterToGroup(group, groupControl); }));
headerContainerElement.AppendChild(addCounterButton);
DataTemplate headerTemplate = new DataTemplate();
headerTemplate.VisualTree = headerContainerElement;
return headerTemplate;
}
and then assign it to the ContentPaneHeaderTemplate.
Thats work fine however the question is about the style.
And one more here: is it possible to add the new item to the ContentPane.Header menu (i.e. Hide, Floating, ... and my items next)
Thanks for answers
Well with regards to styling you could look at the default xaml that we provide in the DefaultStyles directory and use the same template used for the close button but altered to use your content (image/text). With regards to placement, the only way to do that would be to retemplate the PaneHeaderPresenter which is the element within the ContentPane that displays the Header and buttons.
Hi Andrew,
thanks a lot for your response, it is exactly what I need.
So decide to use HeaderTemplate and Styles that are in DefaultStyles directory
here my code
<igDock:ContentPane AllowClose="False" Name="Servers">
<igDock:ContentPane.HeaderTemplate>
<DataTemplate>
<Grid>
<TextBlock>Servers</TextBlock>
<Button Name="AddServerGroup" ToolTip="Add Server Group" Click="AddServerGroup_Click" Style="{StaticResource AddButtonStyleKey}" Content="Add Group" HorizontalAlignment="Right"/>
</Grid>
</DataTemplate>
</igDock:ContentPane.HeaderTemplate>
and in the attach file the styles that I use. They are almost the same, I have just rotate close button and get + button for adding.
But the problem appear when the content pane is activated the foregrouтв color of my button is not changed to white . I'm just beginner in WPF and so it is hard for me to understand the problem. Seems the EventTriggers are in styles but the problem still appear.
Have you any ideas?
When the pane becomes active the PaneHeaderPresenter's Foreground is changed to white (well to the brush keyed by igDock:DockManagerBrushKeys.PaneHeaderActiveTextFillKey). Since foreground is an inherited property I would expect it to affect your button unless you are setting the foreground on your button. I can't say for sure since you don't include your style for AddButtonStyleKey but I'm guessing that if you copied the style for the close button you may have left a setter in their for the foreground. Try removing it since your button wouldn't have a templated parent.