Change tab Title fontsize / color

Docking/MDI for WPF Forum

Posted 8 years ago by sylvain
Version: 16.1.0633
Avatar

Hi,

I try change the font (style, size, color, ...) to all documentwindow header (title).

do you have a sample to do this ?

thanks

 

edit:

my last try is, but doesnt works:

<Style TargetType="docking:DocumentWindow">
<Setter Property="TabbedMdiTabContextContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=TabText}" FontSize="20" Foreground="Red" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>

[Modified 8 years ago]

Comments (6)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Based on the above I assume you mean you want to change what is in a tabbed MDI document tab.  You could change the TabbedMdiHost.TabItemContainerStyle property.  Its default value is:

<Style TargetType="docking:AdvancedTabItem">
	<Setter Property="Header" Value="{Binding TabTextResolved}" />
	<Setter Property="HeaderTemplate">
		<Setter.Value>
			<DataTemplate>
				<TextBlock Text="{Binding Converter={StaticResource TitleConverter}}" TextTrimming="None" TextWrapping="NoWrap" VerticalAlignment="Center" />
			</DataTemplate>
		</Setter.Value>
	</Setter>
</Style>


Actipro Software Support

Posted 8 years ago by sylvain
Avatar

Hi,

 

I try this and a lot of others but I can't change Title Font Size/Color, ...., for a DocumentWindow

 

U says that I need change "TabbedMdiHost.TabItemContainerStyle" but you target "docking:AdvancedTabItem"

Do u have a little sample ?

 thanks

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The above style is correct and you just need to set it to the TabItemContainerStyle property of the TabbedMdiHost in your XAML.  Tab items are rendered via AdvancedTabItem controls.  Then you can change the content of that DataTemplate to whatever you need.  It could use a different font size or even something other than a TextBlock control.


Actipro Software Support

Posted 8 years ago by Brian Pratt
Avatar

I've tried your above suggestion, and still cannot seem to create a custom AdvancedTabItem header in a docking window.  Any other thoughts?

 

Thanks,

Brian

 

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:AdvancedTabStyle"
        xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
      	xmlns:dockingThemes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
        xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared" x:Class="AdvancedTabStyle.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
  <Window.Resources>
    <Style TargetType="docking:AdvancedTabItem" x:Key="mystyle">
      <Setter Property="Header" Value="{Binding TabTextResolved}" />
      <Setter Property="Background" Value="Orange"/>
      <Setter Property="HeaderTemplate">
        <Setter.Value>
          <DataTemplate>
            <TextBlock Text="YO YO YO!  My Personal header!" TextTrimming="None" TextWrapping="NoWrap" VerticalAlignment="Center" />
          </DataTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </Window.Resources>
  <Grid>
    <docking:DockSite>
      <docking:SplitContainer>
        <docking:ToolWindowContainer>
          <docking:ToolWindow Title="Test1"/>
          <docking:ToolWindow Title="Test1"/>
        </docking:ToolWindowContainer>

        <docking:SplitContainer>
          <docking:Workspace>
            <docking:TabbedMdiHost  >
              <docking:TabbedMdiContainer TabItemContainerStyle="{StaticResource mystyle}"  >
                <docking:DocumentWindow Title="DocWindow" FileName="C:\code\audiohtml.htm"/>
                <docking:DocumentWindow Title="DocWindow2" FileName="C:\code\audiohtml.htm"/>
              </docking:TabbedMdiContainer>
            </docking:TabbedMdiHost>
          </docking:Workspace>
        </docking:SplitContainer>
      </docking:SplitContainer>
    </docking:DockSite>
  </Grid>
</Window>
Posted 8 years ago by Brian Pratt
Avatar

Crap.  As usual, I figured it out as soon as I posted it.  The TabitemContiainerStyle is on the TabbedMdiHost, not the TabbedMdiContainer.  Pretty confusing, but here is what was working for me:

 

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:AdvancedTabStyle"
        xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
      	xmlns:dockingThemes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
        xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared" x:Class="AdvancedTabStyle.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
  <Window.Resources>
    <Style TargetType="docking:AdvancedTabItem" x:Key="mystyle">
      <Setter Property="Header" Value="{Binding TabTextResolved}" />
      <Setter Property="Background" Value="Orange"/>
      <Setter Property="HeaderTemplate">
        <Setter.Value>
          <DataTemplate>
            <TextBlock Text="YO YO YO!  My Personal header!" TextTrimming="None" TextWrapping="NoWrap" VerticalAlignment="Center" />
          </DataTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </Window.Resources>
  <Grid>
    <docking:DockSite>
      <docking:SplitContainer>
        <docking:ToolWindowContainer>
          <docking:ToolWindow Title="Test1"/>
          <docking:ToolWindow Title="Test1"/>
        </docking:ToolWindowContainer>

        <docking:SplitContainer>
          <docking:Workspace>
            <docking:TabbedMdiHost  TabItemContainerStyle="{StaticResource mystyle}" >
              <docking:TabbedMdiContainer  >
                <docking:DocumentWindow Title="DocWindow" FileName="C:\code\audiohtml.htm"/>
                <docking:DocumentWindow Title="DocWindow2" FileName="C:\code\audiohtml.htm"/>
              </docking:TabbedMdiContainer>
            </docking:TabbedMdiHost>
          </docking:Workspace>
        </docking:SplitContainer>
      </docking:SplitContainer>
    </docking:DockSite>
  </Grid>
</Window>
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Brian,

Yes, the reason for that is that container instances are transient and are created/destroyed as needed when layout changes occur.  You should never directly reference or set properties directly on any container class (like ToolWindowContainer).  The reason the property is on TabbedMdiHost is that control is always present in the layout and doesn't change with layout changes.  So it's an anchor point so to speak that you can set properties on, and they are set up internally to publish out to all the containers that are within the host.  That's why it works that way.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.