Trouble with ToolWindows in a ControlTemplate

Docking/MDI for WPF Forum

Posted 15 years ago by Jason Otis
Version: 4.5.0480
Avatar
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:

<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>
Here's the custom control:

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";
        }
    }
}

Comments (4)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jason,

For issues like this, please email our support address with a simple sample project that shows the issue instead of posting here. This way we can debug via the project directly and make sure our setup is the same as what you have.

Please email a sample project to our support address and we'll take a look. Thanks!


Actipro Software Support

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks for the sample, we've located and fixed the problem for the next maintenance release.


Actipro Software Support

Posted 14 years ago by Rupeshkumar Panzade
Avatar
We are using Actipro Version 2009.1 build 0506.
But We are still getting the same errors.

System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=Title; DataItem='ToolWindow' (Name='MapViewOnly'); target element is 'ToolWindow' (Name='MapViewOnly'); target property is 'Name' (type 'String')


Regards,
Rupeshkumar
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Rupeshkumar,

We've fixed this issue for the next maintenance release, but for now you can safely ignore these.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.