TabControl not working with classic theme

Does anyone know why the padding property of the TabControl does not render with the classic theme, but works for the Luna theme?

Classic

Luna

The XAML is very simple. I made a 50 left shim so that the problem is obvious in the screenshots.

<!-- Tab control styling -->
        <Style TargetType="{x:Type TabControl}">
            <Setter Property="BorderBrush" Value="Black" />
            <Setter Property="BorderThickness" Value="1,1,1,1" />
            <Setter Property="Padding" Value="50,5,10,5" />
            <Setter Property="Margin" Value="3.5" />
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" />
        </Style>

      

Is there something about a classic theme that I am missing eg. are all uppercase letters ignored?

+3


source to share


1 answer


Using one of the ShowMeTheTemplate tools or Microsoft Expression Blend , you can check out the control templates that Microsoft has implemented by default for different themes.

For Windows Classic, the TabControl control template looks like this:

<ControlTemplate TargetType="{x:Type TabControl}">
    <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
        ...
        <TabPanel .../>
        <Grid ...>
            <Microsoft_Windows_Themes:ClassicBorderDecorator ...>
                <ContentPresenter x:Name="PART_SelectedContentHost" Margin="2,2,2,2" .../>
            </Microsoft_Windows_Themes:ClassicBorderDecorator>
        </Grid>
    </Grid>
    <ControlTemplate.Triggers>
       ...
    </ControlTemplate.Triggers>
</ControlTemplate>

      

For the moon it is like this:

<ControlTemplate TargetType="{x:Type TabControl}">
    <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
        ...
        <TabPanel .../>
        <Border ...>
            <ContentPresenter x:Name="PART_SelectedContentHost" Margin="{TemplateBinding Padding}" .../>
        </Border>
    </Grid>
    <ControlTemplate.Triggers>
       ...
    </ControlTemplate.Triggers>
</ControlTemplate>

      



In Luna, the padding of the TabControl is anchored to the edge of the ContentPresenter; in Windows Classic, the field value is 2.

Personally, I think this is a mistake. You might want to generate a bug report http://connect.microsoft.com/ .

As a workaround, you can define your own content template:

<TabControl>
    <TabControl.ContentTemplate>
        <DataTemplate>
            <ContentPresenter Content="{Binding}" Margin="50,5,10,5"/>
        </DataTemplate>
    </TabControl.ContentTemplate>
    ...
<TabControl>

      

+4


source







All Articles