
I'm trying to use the docking tool windows in a ControlTemplate for a custom control that supports templating. But the ToolWindow doesn't display any of it's content. Everything in the Workspace displays correctly, but I can't get anything to display in the ToolWindows. Do I need to do anything special to use ToolWindows inside a ControlTemplate?
I've created a sample below that demonstrates the problem. The custom control works correctly if I remove all of the docking stuff and just put the controls into a normal panel (StackPanel, DockPanel, etc).
I noticed there is a debug message being output, but I'm not sure if it's related or not:
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=Title; DataItem='ToolWindow' (Name=''); target element is 'ToolWindow' (Name=''); target property is 'Name' (type 'String')
Here's the XAML:Here's the custom control:
I've created a sample below that demonstrates the problem. The custom control works correctly if I remove all of the docking stuff and just put the controls into a normal panel (StackPanel, DockPanel, etc).
I noticed there is a debug message being output, but I'm not sure if it's related or not:
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=Title; DataItem='ToolWindow' (Name=''); target element is 'ToolWindow' (Name=''); target property is 'Name' (type 'String')
Here's the XAML:
<Window x:Class="DockingSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
xmlns:local="clr-namespace:DockingSample"
Title="Window1" Height="600" Width="600">
<Window.Resources>
<ControlTemplate x:Key="testTemplate" TargetType="{x:Type local:CustomControl}">
<docking:DockSite x:Name="dockSite">
<docking:SplitContainer>
<docking:ToolWindowContainer x:Name="toolWindowContainer">
<docking:ToolWindow Title="Toolbar" x:Name="toolWindow">
<TextBlock x:Name="PART_Toolbar" />
</docking:ToolWindow>
</docking:ToolWindowContainer>
<docking:Workspace>
<TextBlock x:Name="PART_Content" />
</docking:Workspace>
</docking:SplitContainer>
</docking:DockSite>
</ControlTemplate>
</Window.Resources>
<local:CustomControl Template="{DynamicResource testTemplate}" />
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
namespace DockingSample
{
public class CustomControl : Control
{
private TextBlock _toolbarText;
private TextBlock _contentText;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_toolbarText = GetTemplateChild("PART_Toolbar") as TextBlock;
_toolbarText.Text = "something about tools...";
_contentText = GetTemplateChild("PART_Content") as TextBlock;
_contentText.Text = "Here is a bunch of content for the main workspace";
}
}
}