Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF覆盖的选项卡项样式可以';不要点击任何东西_C#_Wpf_Wpf Style - Fatal编程技术网

C# WPF覆盖的选项卡项样式可以';不要点击任何东西

C# WPF覆盖的选项卡项样式可以';不要点击任何东西,c#,wpf,wpf-style,C#,Wpf,Wpf Style,我对WPF和XAML比较陌生,我正在尝试覆盖TabControl中TabItems的样式。在我的xaml文件的顶部,我有以下内容: <Window.Resources> <Style TargetType="{x:Type TabItem}"> <Setter Property="Template"> <Setter.Value>

我对WPF和XAML比较陌生,我正在尝试覆盖TabControl中TabItems的样式。在我的xaml文件的顶部,我有以下内容:

<Window.Resources>

    <Style TargetType="{x:Type TabItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid>
                        <Border Name="Border" Margin="0,5,0,0" Background="Transparent"
                                BorderBrush="LightGray" BorderThickness="1,1,1,1">
                            <ContentPresenter x:Name="ContentSite" VerticalAlignment="Center"
                                              HorizontalAlignment="Center"
                                              ContentSource="Header" Margin="12,2,12,2"
                                              RecognizesAccessKey="True">

                            </ContentPresenter>
                        </Border>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Panel.ZIndex" Value="100"/>
                            <Setter TargetName="Border" Property="Background" Value="#EEE9ED"/>
                            <Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,1"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="False">
                            <Setter Property="IsEnabled" Value="False"/>
                            <Setter TargetName="Border" Property="Background" Value="LightGray"/>
                            <Setter TargetName="Border" Property="BorderBrush" Value="Black"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        
        <Setter Property="FontSize" Value="15"/>
        <Setter Property="FontWeight" Value="Bold"/>

    </Style>
    
</Window.Resources>

它将该样式应用于所有选项卡项,并且可以正常工作。这一切看起来都是我想要的。问题是现在我不能点击任何一个。看起来网上的任何样式指南都没有遇到这个问题,所以这可能只是我正在做的一件非常愚蠢的事情,但我真的弄不明白。

问题是
。无法选择
IsEnabled
设置为
False
TabItem
。由于您的
样式
禁用了所有未选择的
选项卡项
,因此这将阻止选择其中任何一项