0
votes

I've made a WPF TabControl with 3 TabItems in it. The problem is that the TabItems themselves are displayed extremely small. I've uploaded a screen print here: http://www.test2468.nl/MJ/StackOverflow/Screenshot%20(3033).png.

As you can see, the items are in the top left corner and barely visible; the non-selected tab items are about 4 mm wide and 2 mm high. I've no idea what could have caused this, and obviously I would have expected the tab items to be displayed in their default sizes. I also note that all other elements (which I've removed here in this Test Window) display in their normal sizes. I do not apply any style to this TabControl or to the window that contains it.

The code is quite simple:

<Window x:Class="MyProject.TestWindow"
            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:MyProject"
            mc:Ignorable="d"
            Title="TestWindow" WindowState="Maximized">

    <TabControl x:Name="tabs" Margin="5 5"  >
        <TabItem></TabItem>
        <TabItem></TabItem>
        <TabItem></TabItem>
    </TabControl>
</Window>

Does anyone have an idea, or maybe even experienced something like this?

1

1 Answers

1
votes

You need to put the TabHeader in order to see the actual width , also you can set the Width of the tab,

Here is a sample

<TabItem Header="FirstTab" Width="500" >
            <Grid Background="#FFE5E5E5">
                <TextBlock HorizontalAlignment="Left"
                   Margin="10"
                   TextWrapping="Wrap"
                   Text="Take pictures of me and put them on the Internet. Meow."
                   VerticalAlignment="Top"
                   Width="500"/>
            </Grid>
 </TabItem>