WPF TabItem内容对齐始终居中

Nel*_*eis 9 wpf tabcontrol alignment

我试图在我的TabItem中放入一些内容,但是我无法添加填充TabItem空间的容器.我添加的任何东西都显示在中心位置.

我正在使用来自WPF工具包(WhistlerBlue.xaml)的主题,所以我想也许是因为什么导致了我这个问题.

我无法删除主题,因为我需要它.最多我可以改变它的内容,但我是WPF的新手,并且不知道我应该改变什么.

我的TabControl看起来像这样:

<TabControl Margin="0,71.25,0,206.25" Name="tabControl1" TabStripPlacement="Left">
    <TabItem Name="tabItem1" FlowDirection="LeftToRight" FontSize="22" Height="200" Width="60" >
        <TabItem.Header>
            <StackPanel Orientation="Horizontal" >
                <Image Height="40" Width="40" Margin="20,0,0,0" VerticalAlignment="Center"></Image>
                <TextBlock Margin="15,0,25,0" VerticalAlignment="Center" FontWeight="Bold">
                    Header
                </TextBlock>
            </StackPanel>
        </TabItem.Header>
        <TabItem.Content>
            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,0,0" >
                <TextBlock>Test</TextBlock>
            </StackPanel>
        </TabItem.Content>
    </TabItem>
</TabControl>
Run Code Online (Sandbox Code Playgroud)

有类似的问题,但它没有答案:在WPF中,如何获取tabItem的内容以填充可用空间?

有人能帮我吗?谢谢.

Nel*_*eis 21

好的,我找到了答案.

主题的.xaml以TabItem的这些设置开始:

<Style d:IsControlPart="True" TargetType="{x:Type TabItem}">
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
Run Code Online (Sandbox Code Playgroud)

我已将Center改为Stretch,问题解决了.

我真的需要从一本书中学习WPF,而不仅仅是尝试一下.