I'm trying to style ContentPane. Everything works well, up until I'm dragging pane from the DocumentContentHost....
Let's take an example with the following XAML code:
<Window x:Class="ContentPaneStylingBug.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:igDock="http://infragistics.com/DockManager"
Title="MainWindow" Height="350" Width="700">
<Grid>
<igDock:XamDockManager Grid.Row="1" x:Name="xamDockManager1">
<igDock:XamDockManager.Panes>
<igDock:SplitPane SplitterOrientation="Horizontal" igDock:XamDockManager.InitialLocation="DockedLeft" MinWidth="200">
<igDock:ContentPane Header="Solution Explorer" />
</igDock:SplitPane>
<igDock:SplitPane SplitterOrientation="Horizontal" igDock:XamDockManager.InitialLocation="DockedRight" MinWidth="200">
<igDock:ContentPane Header="Properties Window" />
</igDock:XamDockManager.Panes>
<igDock:DocumentContentHost>
<igDock:SplitPane>
<igDock:TabGroupPane Margin="5">
<igDock:ContentPane Header="Function1" />
<igDock:ContentPane Header="Function2" />
<igDock:ContentPane Header="Function3" />
</igDock:TabGroupPane>
</igDock:DocumentContentHost>
</igDock:XamDockManager>
</Grid>
</Window>
Now drag for example "Function2" to the left ContentPane just like in the following pictures:
Now, let's take the project and edit the style of the ContentPane in Blend.
We get the following XAML (using Edit Template à Edit a Copy):
<Window.Resources>
<Style x:Key="ContentPaneStyle1" TargetType="{x:Type igDock:ContentPane}">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="BorderBrush" Value="{DynamicResource DockManagerBrushKeys.ContentPaneBorderFillKey}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="TabHeader">
<Setter.Value>
<Binding Path="Header" RelativeSource="{RelativeSource Self}">
<Binding.Converter>
<igDock:ContentValidationConverter ErrorMessage="[Error: The Header of the ContentPane is set to an element. The Header is used as the default TabHeader and in the PaneNavigator. An element cannot be shown in multiple locations. Set the HeaderTemplate to the element that should be displayed in the pane caption and navigator and set the TabHeader or TabHeaderTemplate as needed.]"/>
</Binding.Converter>
</Binding>
</Setter.Value>
</Setter>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Template">
<ControlTemplate TargetType="{x:Type igDock:ContentPane}">
<AdornerDecorator>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<DockPanel Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
<igDock:PaneHeaderPresenter ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" DockPanel.Dock="Top" Visibility="{TemplateBinding HeaderVisibility}"/>
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Visibility="{TemplateBinding ContentVisibility}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</DockPanel>
</Border>
</AdornerDecorator>
</ControlTemplate>
</Style>
</Window.Resources>
<igDock:ContentPane Header="Solution Explorer" Style="{DynamicResource ContentPaneStyle1}" />
Do the same thing of dragging "Function2" to the left ContentPane.You will get ArgumentNullException.... "Value cannot be null. Parameter name: pane".
At Infragistics.Windows.DockManager.DockManagerUtilities.ThrowIfNull
Anyway to still style the ContentPane, but bypass this exception?
10x
It's usually better to start with a copy of the xaml then to use Blend to infer the template since it can lose some information. In this case add the following to the PaneHeaderPresenter in that template:
DataContext="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}}"
Hi, thank you. Actually with Blend I can usually get the original style and change it a little bit (cause I still want the menus and buttons).
I also tried using Style Snooper and got a more detailed XAML of the ContentPane, but it still doesn't solve the problem.
Thank you for the solution, it works like a charm... Either way, how would I know how to create a new template for one of the controls?
(I could never have guessed that I had that line missing).
Is there any place where I can get the complete XAML of the elemens so I can style them correctly?
The default xaml is provided in the DefaultStyles directory (e.g. C:\Program Files\Infragistics\NetAdvantage 2010.3\WPF\DefaultStyles\DockManager). In this case we should probably pick up the ContentPane for the PaneHeaderPresenter even if that property is not set so we'll look to address this specific issue in an upcoming SR.
Thanks :-)