Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi forum,

there's a TabControl in a WPF software I have to make touch-friendly. I would like to increase the height of all the headers to 48 pixels so they fit nicely with the buttons that alre already large enough for fingers to push them.

But there seems to be no <header.height> property to change.

I have seen several articles on hiding the header altogether or ones that completely redesign the header in arbitrary ways.

Is there a way to only change the Height or MinimumHeight or so for a TabControl header?

What I have tried:

XAML
<Window.Resources>
    <ControlTemplate x:Key="TouchTabControl" TargetType="TabControl">
        <ContentPresenter Heading.Height="48" />
    </ControlTemplate>
</Window.Resources>
Error: Heading.Height is not supported by a Windows Presentation Foundation (WPF)-Project.

XAML
<Window.Resources>
    <Style TargetType="TabControl">
        <Setter Property="HeaderTemplate">
        <!--Error1-->
            <Setter.Value>
                <ContentPresenter>
                    <ContentPresenter.Content>
                        <TextBlock FontSize="48" Text="{TemplateBinding Content}" />
                        <!--Error2-->
                    </ContentPresenter.Content>
                </ContentPresenter>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>

Error1: "HeaderTemplate" has not been recognized or is not accessible.
Error2: "Content" has not been recognized or is not accessible.
Posted
Updated 20-Oct-20 1:02am
v2

Just change the Height of one Header:
XML
<Grid>
   <TabControl>
      <TabItem>
         <TabItem.Header>
            <Grid Height="48">
               <TextBlock Text="Press me"
                          VerticalAlignment="Center" />
            </Grid>
         </TabItem.Header>
      </TabItem>
      <TabItem Header="Me Too" />
   </TabControl>
</Grid>
 
Share this answer
 
Comments
lukeer 20-Oct-20 4:02am    
Thank you.
That looks as if I would essentially create a custom header of the size I want it to have.

Is it possible to not do that for a particular TabControl but in a way that it can be applied to several (or all) TabControls in a Window?
Starting here[^], I came up with this:
XAML
<Style TargetType="{x:Type TabItem}">
    <Setter Property="HeaderTemplate">
        <Setter.Value>
            <DataTemplate>
                <ContentPresenter Content="{TemplateBinding Content}" Height="48" />
            </DataTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="Padding" Value="3" />
</Style>
Thank you everyone for brooding over this with me.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900