wpf - 如何从选项卡控件中删除白色边框?
问题描述
我一直在寻找模板,但找不到任何东西。 例子
到目前为止我的 XAML:
<TabControl HorizontalAlignment="Left" Height="285" BorderThickness="0" Margin="10,56,0,0" VerticalAlignment="Top" Width="495">
<TabItem Header="Main" Foreground="#38acfc" BorderThickness="0" Background="#0c142c" FontFamily="Myriad Pro Cond" FontSize="14" Style="{DynamicResource CustomTabControl}">
<Grid Background="#0c142c"/>
</TabItem>
</TabControl>
解决方案
使用此 ControlTemplate :
<Style TargetType="{x:Type TabControl}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid KeyboardNavigation.TabNavigation="Local">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TabPanel
Name="HeaderPanel"
Grid.Row="0"
Panel.ZIndex="1"
Margin="0,0,4,-1"
IsItemsHost="True"
KeyboardNavigation.TabIndex="1"
Background="Transparent" />
<Border
Name="Border"
Grid.Row="1"
Background="White"
BorderBrush="Transparent"
BorderThickness="1"
CornerRadius="2"
KeyboardNavigation.TabNavigation="Local"
KeyboardNavigation.DirectionalNavigation="Contained"
KeyboardNavigation.TabIndex="2" >
<ContentPresenter
Name="PART_SelectedContentHost"
Margin="0"
ContentSource="SelectedContent" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="Gray" />
<Setter TargetName="Border" Property="BorderBrush" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
推荐阅读
- python - pyqt QStandardItemModel 有没有办法从模型中完全删除值?
- wordpress - 谷歌站点地图插件生成不正确的 URL
- php - 在 php、mysql 中以“内联编辑”样式编辑回显输出-
- jquery - HTML 访问密钥 (alt+s) 在 CK 编辑器中不起作用
- powershell - 如何使用 powershell 中的命令将 sudo 用户添加到 WSL?
- fusionauth - 是否可以在用户注册期间强制执行 2FA 配置?
- ruby - Rails:Active Storage 变体生成一个附加文件
- angular - JSON值降序排序的问题
- sql - 如何编写只选择一些字母的sql?
- php - 如何在 php-fpm 后面的 docker 中获取 laravel 的日志?