ToolWindow Tab font size

Docking/MDI for WPF Forum

Posted 14 years ago by Bjørnar Sundsbø - Norway
Version: 9.1.0507
Avatar
I would like to be able to override the font size of the text displayed in the tabs for ToolWindowContainer and AutoHideTabItem in a simple way using a ComponentResourceKey without affecting all the other texts inside the ToolWindow.

Is this something you could easily expose? My current workaround leads to too much rewrite of controltemplates which might later lead to loss of bug fixes to XAML in new releases.

Best regards

Bjørnar Sundsbø


Bjørnar Sundsbø

Comments (5)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bjørnar,

In WPF Studio 2009.1 build 0506, we updated the docking windows to derive from HeaderedContentControl. This change allows you to customize the content of the tabs. So, what you could do is build a DataTemplate that uses your desired font size, and use that in your tool windows.

There is also a QuickStart that shows how to leverage this new feature.


Actipro Software Support

Posted 14 years ago by Bjørnar Sundsbø - Norway
Avatar
Nifty. I noticed the change in the release notes, but didn't make this connection when solving the problem. Thanks. I will have a look at it.

/B


Bjørnar Sundsbø

Posted 13 years ago by Bjørnar Sundsbø - Norway
Avatar
To quote Queen: "I'm going slightly mad..."

I've been trying for a while to get custom toolwindow header working properly, and that is where the Queen quote comes into play.

The behavior of the custom header changes based on state of the window. What I'm trying to do, have a custom TextBlock with a different font size inside the header.

This scenario can be reproduced in the Docking Window Header QuickStart sample.
I try to set the following HeaderTemplate on the ToolWindow for Class View.

<docking:ToolWindow.HeaderTemplate>
    <DataTemplate>
        <TextBlock AutomationProperties.Name="Title" FontFamily="Courier New" FontStyle="Italic"
            Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type docking:DockingWindow}}, Path=Title, Converter={StaticResource DocumentTitleConverter}}"
            TextTrimming="CharacterEllipsis" VerticalAlignment="Center" />
    </DataTemplate>
</docking:ToolWindow.HeaderTemplate>
When placing the ToolWindow in AutoHide, the header disappears. When docking the window again, it is displayed properly.

Setting the Header directly when declaring the toolwindow does not produce this behavior. In my application, I want to use this template on all toolwindows (want to use a dynamic fontsize which will be a few points larger than all the other text in the application). I then declare a Style for ToolWindow with the same HeaderTemplate as specified in this post, I get the same behavior.

What is going on here? I have also tried to declare a styled TextBlock inside the header for each toolwindow and got the same disappearing behavior when autohiding. I have quite a few ToolWindows in my application, so declaring the same header multiple places is messy in my opinion.

By the way, I also tried to set the style in Generic.xaml, but then it is not applied at all. Curiouser and curiouser... Declaring it inside the DockSite works. Of course, it is only used inside this one docksite, so declaring it at application level is not really necessary.

PS: I'm using the latest release.
PS2: Setting MinWidth=50 for the TextBlock, this width is maintained. The title binding does not seem to live when autohide.
PS3: While rubber-ducking here, I found out the binding to Title can't be resolved as there is no ancestor of type DockumentWindow.

Bjørnar


[Modified at 12/07/2010 01:17 PM]


Bjørnar Sundsbø

Posted 13 years ago by Bjørnar Sundsbø - Norway
Avatar
The solution was not too obvious based on some of the samples. The following code does work. I just had to change the declaration of the ToolWindow to use Header to contain the title instead of using the Title property.

<Docking:TitleConverter x:Key="TitleConverter" Prefix="20" Suffix="15" Patch="..." />
<Style x:Key="{x:Static Themes:DockingCommonDictionary.ToolWindowStyleKey}"
       TargetType="{x:Type Docking:ToolWindow}"
       BasedOn="{StaticResource {x:Static Themes:DockingCommonDictionary.ToolWindowStyleKey}}">
    <Setter Property="HeaderTemplate">
        <Setter.Value>
            <DataTemplate>
                <TextBlock AutomationProperties.Name="Title" 
                           Margin="3" 
                           MinWidth="50"
                           TextAlignment="Center"
                           FontSize="{Binding FontSize, RelativeSource={RelativeSource AncestorType={x:Type Ribbon:RibbonWindow}}, Converter={x:Static Data:BindingConverters.FontSizeConverter}, ConverterParameter=2}"
                           Text="{Binding Converter={StaticResource TitleConverter}}" />
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>


Bjørnar Sundsbø

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bjørnar,

When a ToolWindow is auto-hidden, it's tab is displayed by an AutoHideTabItem (using the Title, Header, HeaderTemplate, HeaderTemplateSelector from the ToolWindow). So your binding that looks for a DockingWindow ancestor would fail. By using Header, you are eliminating the RelativeSource and successfully binding to the Title.


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.