Xaphann
Xaphann

Reputation: 3677

Customize WPF TabControl TabItem Header

I am using a TabControl as a makeshift wizard. So I don't want the user clicking to the next tab. I am able to do it like this;

<TabControl Name="myTabControl" >
    <TabItem Visibility="Collapsed">
        <!-- XMAL stuff -->
    </TabItem>
    <TabItem Visibility="Collapsed">
        <!-- XMAL stuff -->
    </TabItem>
</TabControl>

The issue being is there is a white border that appears;

enter image description here

How do I remove the white border?

thanks

edit: Doing some more testing it appears the white border is not a border but the background of the TabControl. I was able to fix it by doing this;

<TabControl Name="myTabControl" >
    <TabItem Visibility="Collapsed">
        <Grid Margin="-2">
            <!-- XMAL stuff -->
        </Grid>
    </TabItem>
    <TabItem Visibility="Collapsed">
        <Grid Margin="-2">
            <!-- XMAL stuff -->
        </Grid>
    </TabItem>
</TabControl>

Seems like a stupid way of fixing this

Upvotes: 0

Views: 1408

Answers (1)

Eugene Podskal
Eugene Podskal

Reputation: 10401

You could try to set the tabitem's template(it is actually tabitem header's template) to empty:

<TabControl.Resources>
    <Style TargetType="TabItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabItem"/>
            </Setter.Value>
        </Setter>
    </Style>
</TabControl.Resources>

Also, try to set border thickness to zero:

<TabControl BorderThickness="0">

Upvotes: 3

Related Questions