0

当我将图像设置为 TabItem 的标题时,它看起来像某个灰色区域中的图像。如何去除这个周边区域? 在此处输入图像描述

<TabControl TabStripPlacement="Left" 
        HorizontalContentAlignment="Left" 
        VerticalContentAlignment="Top">
<TabItem ToolTip="Элементы, в которых найдены несоответствия" Height="200" 
         Style="{StaticResource TabItemHeaderImageStyle}">
    <TabItem.Header>
        <Image Source="{StaticResource CheckImage}"
               Margin="0"
               Height="25" Width="25" />
    </TabItem.Header>
    <ListBox ItemsSource="{Binding unmatched.vs}"
             MaxHeight="200" 
             ItemTemplate="{StaticResource VertexPresenterNotConformTemplate}" />
</TabItem>
<TabItem ToolTip="Элементы, соответствующие шаблону"
         Style="{StaticResource TabItemHeaderImageStyle}">
    <TabItem.Header>
        <Image Source="{StaticResource UncheckImage}"
               Height="25" Width="25" />
    </TabItem.Header>
    <ListBox ItemsSource="{Binding unmatched.vs}"
             MaxHeight="200" 
             ItemTemplate="{StaticResource VertexPresenterConformTemplate}" />
</TabItem>         

 <Style x:Key="TabItemHeaderImageStyle" TargetType="{x:Type TabItem}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type TabItem}">
                <Grid>
                    <Border Name="Border" 
                            Margin="0,0,-4,0"                                
                            BorderThickness="1,1,1,1" 
                            CornerRadius="2,12,0,0" >
                        <ContentPresenter x:Name="ContentSite"
                                          VerticalAlignment="Center"
                                          HorizontalAlignment="Center"
                                          ContentSource="Header"
                                          Margin="12,2,12,2"
                                          RecognizesAccessKey="True"/>
                    </Border>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

我希望的(TabItem 的标题在彼此下方,周围没有灰色区域): 在此处输入图像描述

4

1 回答 1

0

TabItem 的标题周围可能有一个灰色的边框(因此在图像周围产生阴影)。请参阅此链接以获取 TabItem ControlTemplate。

我会尝试摆弄 controltemplate 或使用WpfInspector之类的应用程序来查看模板有什么问题并获得正确的值。

于 2012-08-16T14:33:06.780 回答